Wednesday 23 April 2014

How to create Session in jsp

             
STEP 1:   Create folder in webapps which is exising in Apache Tomcat folder
           
                Folder name as Session_example
STEP 2:   Now in Session_example folder you have to create index.html file and code as Below


               <html>

               <head>

               <title>Wel come</title>


               </head>

              <body bgcolor="#660099">



            <form name="form1" method="post" action="http://localhost:8080/Session_example             
                                                                                                 /sessionex.jsp" >

               <h1 align="center"><u>Sesssion examlpe</u></h1>
               <table width="350" align="center" style="font-family:Calibri;color:white;"  cellpadding="0" 
                cellspacing="0">
               <tr>
               <td><br>
                                Enter your name:&nbsp;&nbsp;</td>
               <td><br><input type="text" name="name" value=""> </td>
               </tr>
               <tr>
               <td><br>Enter your Surname:&nbsp;&nbsp;</td>
               <td ><br>
               <input type="text" name="sname" value=""></td>
               </tr>
               <tr>
               <td>&nbsp;</td>
               <td colspan="2"><br><input type="submit"  value="show"></td>
               </tr>
    
              </table>

              </form>

              </body>
              </html>

       
             I hope you have created it.


STEP 3: In Session_example folder create your jsp file in notepad code as below
              as per below code
           
           <% 


                String Name = request.getParameter("name");
                String sName = request.getParameter("sname");


                if (Name != null && Name.length() > 0)
                     {
                           session.setAttribute(Name, sName);
                     }
         
         
                 String value = session.getAttribute(Name).toString();
                 out.println("Your Session Name : "+Name + "<br>" +"Your Session Value : "+ value);




              %>





   STEP 4:After complation of your programm you have to open Apche server in
              browser
    
             like ,
                    http://localhost:8080/

            click on manager apps
             and then clcik on list of Application
            After that you found your example name as Session_example
           Click on Session_example link

   

Enjoy........   


Download Example

Downlod files and Extract in webapps folder

How to print Request Header Information using Servlet

First of all,

STEP 1:   Create folder in webapps which is exising in Apache Tomcat folder
           
                Folder name as RequestHeaders

STEP 2:   Now in Hello folder you have to create index.html file and code as Below


                 <html>
                 <head>
                 <title>Wel come</title>
                 </head>

               <body >
                              <a href="RequestHeaders">Click here</a>


               </body>
                </html>
       
             I hope you have created it.

STEP 3: After that create new folder in RequestHeaders foder which name is WEB-INF

STEP 4: Now create one file which name is web.xml and make sure it's extenstion is .xml and coded
              with below code
        
             <web-app>
                 <servlet>
                               <servlet-name>RequestHeaders</servlet-name>
                               <servlet-class>RequestHeaders</servlet-class>
                </servlet>
          
                <servlet-mapping>
                              <servlet-name>RequestHeaders</servlet-name>
                              <url-pattern>/RequestHeaders</url-pattern>
               </servlet-mapping>

             </web-app>

            this file used to mapping between servlet to your servlet file
  
STEP 5: Now create one folder in WEB-INF foder which name is classes

STEP 6: In classes folder create your servlet file which name is Hello.java
              complie it
              as per below code
           
              import java.io.*;
              import javax.servlet.*;
              import javax.servlet.http.*;
              import java.util.*;



           public class RequestHeaders extends HttpServlet {
           public void doGet(HttpServletRequest request,
                                                              HttpServletResponse response)
                     throws ServletException, IOException
    {
               response.setContentType("text/html");
               PrintWriter out = response.getWriter();
               String title = "Servlet Example: Showing Request Headers";
               String docType =
                        "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
                            "Transitional//EN\">\n";
                out.println(docType +
                "<HTML>\n" +
                "<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +
                "<BODY BGCOLOR=\"#FDF5E6\">\n" +
                "<H1 ALIGN=\"CENTER\">" + title + "</H1>\n" +
                "<B>Request Method: </B>" +
                request.getMethod() + "<BR>\n" +
                "<B>Request URI: </B>" +
                request.getRequestURI() + "<BR>\n" +
                "<B>Request Protocol: </B>" +
                request.getProtocol() + "<BR><BR>\n" +
                "<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
                "<TR BGCOLOR=\"#FFAD00\">\n" +
                "<TH>Header Name<TH>Header Value");
                  Enumeration headerNames = request.getHeaderNames();

                    while(headerNames.hasMoreElements()) {
                      String headerName = (String)headerNames.nextElement();
                      out.println("<TR><TD>" + headerName);
                  out.println("    <TD>" + request.getHeader(headerName));
            }
                    out.println("</TABLE>\n</BODY></HTML>");
         }



                 public void doPost(HttpServletRequest request,
                                                     HttpServletResponse response)
                                                     throws ServletException, IOException {
                                                  doGet(request, response);
                                                  }
                               }


STEP 7:After complation of your programm you have to open Apche server in
              browser
    
             like ,
                    http://localhost:8080/

            click on manager apps
             and then clcik on list of Application
            After that you found your example name as RequestHeaders,
           Click on RequestHeaders link

   

Enjoy........  

Download Example

Downlod files and Extract in webapps folder

How to print Hello world in jsp


STEP 1:   Create folder in webapps which is exising in Apache Tomcat folder
            
                Folder name as Print Hello

STEP 2:   Now in Print Hello folder you have to create index.html file and code as Below


                 <html>
                 <head>
                 <title>Wel come</title>
                 </head>

               <body >
                              <a href="Hello.jsp">Click here</a>


               </body>
                </html>
        
             I hope you have created it.


STEP 3: In Print hello folder create your jsp file in notepad code as below
              as per below code
           
               <%

                     out.println("Hello,world");

                %>
   
STEP 7:After complation of your programm you have to open Apche server in
              browser
     
             like ,
                    http://localhost:8080/

            click on manager apps
             and then clcik on list of Application
            After that you found your example name as Print Hello
           Click on Hello link

    

Enjoy........   

Download Example


Downlod files and Extract in webapps folder

How to craete colorful comments text in winrar

First of all, go to on your command prompt

type below code

copy con D:\esc.txt

now hold down  ALT key and type 27 from your num pad.  Now

Release ALT key


Goto to your D: drive and open esc.txt and paste below color code befor your text


0;1;37m
White text, Black background.

[0;1;37;30m
Grey text, Black background.

[0;1;37;31m
Red text, Black background.

[0;1;37;32m
Green text, Black background.

[0;1;37;33m
Yellow text, Black background.

[0;1;37;34m
Blue text, Black background.

[0;1;37;35m
Fuxia text, Black background.

[0;1;37;36m
Celestial text, Black background.

here are the 8 foreground color codes:

    30.......Black
    31.......Red
    32.......Green
    33.......Yellow
    34.......Blue
    35.......Magenta
    36.......Cyan
    37.......White

And 8 background color codes:

    40.......Black (deafult)
    41.......Red
    42.......Green
    43.......Yellow
    44.......Blue
    45.......Magenta
    46.......Cyan
    47.......White




Select your file to create winrar file

Right click on file and click on  Add  to Archive... option

Select comment window and click on browse button

pick up esc.txt file which you created  and press ok button



Enjoy

 Download    esc.txt file

 

Friday 18 April 2014

How to print Hello World in servlet

Let us start Servlet first programm,

First of all,

STEP 1:   Create folder in webapps which is exising in Apache Tomcat folder
             
                Folder name as Hello

STEP 2:   Now in Hello folder you have to create index.html file and code as Below


                 <html>
                 <head>
                 <title>Wel come</title>
                 </head>

               <body >
                              <a href="Hello">Click here</a>


               </body>
                </html>
         
             I hope you have created it.

STEP 3: After that create new folder in Hello foder which name is WEB-INF

STEP 4: Now create one file which name is web.xml and make sure it's extenstion is .xml and coded
              with below code
          
             <web-app>
                 <servlet>
                               <servlet-name>Hello</servlet-name>
                               <servlet-class>Hello</servlet-class>
                </servlet>
            
                <servlet-mapping>
                              <servlet-name>Hello</servlet-name>
                              <url-pattern>/Hello</url-pattern>
               </servlet-mapping>

             </web-app>

            this file used to mapping between servlet to your servlet file
  
STEP 5: Now create one folder in WEB-INF foder which name is classes

STEP 6: In classes folder create your servlet file which name is Hello.java
              complie it
              as per below code
           
               import java.io.*;
               import javax.servlet.*;
               import javax.servlet.http.*;

               public class Hello extends HttpServlet {

                                public void doGet(HttpServletRequest request, HttpServletResponse response)
                                                                                            throws IOException, ServletException
                                {
                                         response.setContentType("text/html");
                                         PrintWriter out = response.getWriter();
                                          out.println("<html><body>Hello World!</body></html>");
                                }
                                }

STEP 7:After complation of your programm yu have to open Apche server in
              browser
      
             like ,
                    http://localhost:8080/

            click on manager apps
             and then clcik on list of Application
            After that you found your example name as Hello
           Click on Hello link

     

Enjoy........   

DOWNLOAD EXAMPLE


Downlod files and Extract in webapps folder
         
 

Thursday 10 April 2014

How to install Apache Tomcat and set Environment variable path

Download and install jre and jdk

From here: http://java.com/en/download/index.jsp
--------------------------------------------------------
Download and install Apache Tomcat by give must proper port no as 8080 or as you like no
and username and password while installing

from here:   http://tomcat.apache.org/download-70.cgi
--------------------------------------------------------

After Completion of installation

you must have to set environment for Apache Tomcate

STEP 1:
                 Right click on MY COMPUTER icon
              
                Click on PROPERTIES

                select ADVANCE TAB

                Click on Environment variable
STEP 2:
                Click on NEW in System variable  tab
             
            
                in VARIABLE NAME  : CLASSPATH
                    VARIABLE VALUE : C:\Program Files\Apache Software Foundation\
                                                            Tomcat 7.0\lib\servlet-api.jar;


                as per shown in below image.

            
     




      after that set click on NEW button and set JAVA_HOME as per shown in below image


                  in VARIABLE NAME  : JAVA_HOME
                    VARIABLE VALUE :C:\Program Files\Java\jdk1.7.0_51

                         







          after that set click on NEW button and set PATH as per shown in below image


                  in VARIABLE NAME  : PATH
                    VARIABLE VALUE :   C:\Program Files\Java\jdk1.7.0_51\bin;



           


                           


   now go to cmd and check java and javac command that works properly or not .
   now start Apache tomcat Service and open browser and
   goto to localhost

   enjoy servlet and jsp programm........

    Thanks you.........!!!!!

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...