...::: Recent Updates :::...

Sunday, July 8, 2012

Android Application to understand Menu Options and Changing Color accordingly

Question -7


Understand Menu option.
a. Create an application that will change color of the screen, based on selected options from the
menu.




Step 1: Create New Project in eclipse.


Step 2: Edit MainActivity XML file in folder res/layout folder of your project

Step 3: Edit MenuActivity XML file in folder res/menu folder of  your project

Step 4: Edit MainActivity Java file in folder src/package/ folder of your project


Android Application to Understand Spinner value changing images

Question - 6

Understand resource folders :
a. Create spinner with strings taken from resource folder(res >> value folder).
b. On changing spinner value, change image.





Step 1: Create New Project in eclipse and go to res/layout folder.


Step 2: Add 5 Images of your choice into res/drawable-hdpi/ folder of your project.

Step 3: Edit Activity_Spinner XML file in res/layout/ folder of your project.

Step 4: Edit Activity Spinner Java file in src/package/ folder of your project.


Saturday, July 7, 2012

Android Application for List Activity.

Question -5

Create an application that will pass some number to the next screen and on the next screen that number of items should be display in the list.






Step 1: Create New Project in Eclipse.

Step 2: Edit Main ListActivity xml file from res/layout folder of your project.

Step 3: Add New ListDisplay xml file to your res/layout folder of your project.

Step 4: Edit Main List Activity Java file from src/package/ folder of your project.

Step 5: Add New ListDisplay Java class file to your src/package/ folder of your project.


Android Application On successful login open browser with any URL.



Question -4

Create an Login application as above . On successful login , open browser with any URL.



Step 1: Create New Project in Eclipse.

Step 2: Edit Main_Activity layout xml file from res/layout folder in your project


Step 3: Edit MainActivity.java file from src/package/ folder in your project



Create login application where you will have to validate EmailID(UserName). Till the username and password is not validated, login button should remain disabled.


Question -3

Create login application where you will have to validate EmailID(UserName). Till the username and password is not validated, login button should remain disable.





Step 1: Create New Project in Eclipse.
Step 2: Edit Main Layout XML file from res/layout folder


Step 3: Edit MainActivity.java file from scr/package/ folder



Android Application to understand Activity - Intent



Question -2

To understand Activity, Intent
a. Create sample application with login module.(Check username and password)
b. On successful login, go to next screen. And on failing login, alert user using Toast.
c. Also pass username to next screen



Step 1: Create New Project in eclipse 
Step 2: Edit main activity layout xml file.


Step 3: Add new layout xml file sucess.xml in res/layout folder.


Step 4: Edit Main Activity Java File from src/package/MainActivity.java



Step 5: Add new Java file in src/package/sucess.java



Android Hello World Application



Question -1

Create Hello World Application that will display  "Hello World" in the middle of the  screen in the  red color and white background.





Step 1: Create New Project in eclipse and go to res/layout folder.
Step 2: Edit MainActivity XML file.



Wednesday, June 20, 2012

Filter

Download Source Code
<!-- Create a servlet filter that logs all access to and from servlets in an application and
prints the following to System.out: or in your terminal or konsole
a. the time
d. the URL of the resource requested
e. the IP address of the visitor-->
<!-- display_Filter.java Filter Class-->
package FilterDisplay;
import java.io.*;
import javax.servlet.*;
import java.util.*;
import javax.servlet.http.*;
public class display_Filter implements Filter
{
    public void doFilter(ServletRequest request,ServletResponse response,FilterChain fc)throws ServletException,IOException
    {
        HttpServletRequest req=(HttpServletRequest)request;
        System.out.println("Requesting URL:-"+req.getRequestURL());
        System.out.println("Host or Ip address:-"+req.getRemoteHost());
        System.out.println("Date Of Accessing Request And Response Time:- "+new Date());
        fc.doFilter(request,response);
    }
    public void init(FilterConfig config){}
    public void destroy(){}
}
<!-- filter is implemented in this Servlet  Simple.java-->
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Simple extends HttpServlet
{
    public void doGet(HttpServletRequest requeset,HttpServletResponse response)throws ServletException,IOException
    {
        response.setContentType("text/html");       
        PrintWriter out=response.getWriter();
        out.println("<html><head><title>fileter Example</title></head><body>");
        out.println("Hello See Your Terminal Please :) ");
        out.println("</body></html>");
        out.close();
    }
}
<!--web.xml file -->
<web-app>
    <servlet>
        <servlet-name>Display</servlet-name>
        <servlet-class>Simple</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Display</servlet-name>
        <url-pattern>/Maulin_Filter</url-pattern>
    </servlet-mapping>
    <filter>
        <filter-name>Display_Filter</filter-name>
        <filter-class>FilterDisplay.display_Filter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>Display_Filter</filter-name>
        <servlet-name>Display</servlet-name>
    </filter-mapping>
</web-app>

Monday, June 18, 2012

generate page not found error

Download Code
<!--Write a servlet that returns a “page not found” error page (404) unless the user supplies a favouriteLanguage request (form) parameter with a value of “Java.” -->

<!-- Check.java -->
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Check extends HttpServlet
{
    public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
    {
        response.setContentType("text/html");
        PrintWriter out=response.getWriter();
        String language=request.getParameter("language");
        language=language.toLowerCase();
        if(language.equals("java"))   
        {
            out.println("<html><head><title>Error Page :)</title></head><body>");
            out.println("<h1>Welcome dude nice Choice</h1></body></html>");
        }
        else
        {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);       
        }
        out.close();
    }
}

<!-- favlanguage.html -->
<html>
<head>
    <title>Favourate Language</title>
</head>
    <body>
        <form name=f1 method="get" action="/NotFoundError/error_page">
            Enter Your favourate Language:-<input type="text" name="language" /><br>
            <input type="submit" name="submit" value="Submit" />
        </form>
    </body>
</html>

Jstl "" error Handling :)

You can Download Code from below link
http://www.4shared.com/zip/-krrH0XX/jstlTest.html
<!----- copy the two jar file (jstl.jar,standard.jar)in your webapplication lib directory .you will find this two jar file in /home/maulin/apache-tomcat-7.0.25/webapps/examples/WEB-INF/lib or in wondow$ you will find in webapps\examples\WEB-INF\lib directory -->
<!--- My Directory Structure Show Below you can easily understand it-->




<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
        <title>
                Test
        </title>

</head>
        <body>
                <c:catch var="Maulin">
                        <% int a=0/0; %>
                </c:catch>
                Exception Message:- ${Maulin.message}
        </body>
</html>