|  Home   |  Contact Us   |  Online Exam   |  Tech World   |  Jobs    |  Member Login
Java Interview Questions
Jdbc Interview Questions
Servlet Interview Questions
Jsp Interview Questions
Struts Interview Questions
Ajax Interview Questions
Webservice Interview Questions
Designpattern Interview Questions
J2me Interview Questions
EJB Interview Questions
Spring Interview Questions
Hibernet Interview Questions
Enterprise IT Training
Java Program Examples
Ask Technical Expert!
Write Online Exam and Get Job Opportunity Here!
        STEPS TO EXECUTE JSP          
Steps to Execute Jsp  |   Example Jsp program

step 1 : Create your UserRequest Page
      Create a html page, from that we are going to send request to the server.
For Example : Demo.html

     <html>
     <head><title>Form Post Example</title></head>
     <body>
     <center><table border="2">
     <tr>
     <td>JSP Form Post Example</td>
     </tr>
     <td>
     </center></table>
     <center><table border="2">
     <form action="nextPageToPost.jsp" action="post">
     <center><table border="2">
     <tr>
     <td align="center"colspan="2"><h4>
     Enter data for post to next page <h4></td>
     </tr>
     <tr>
     <td>Enter your name</td>
     <td><input type="text" name="name"></td>
     </tr>
     <tr>
     <td>Enter your password</td>
     <td><input type="password" name="password"></td>
     </tr>
     <tr>
     <td><b>Sex</b></td>
     <td><input type="radio" name="sex" value="Male">Male</td>
     <td><input type="radio" name="sex" value="Female">Female</td>
     </tr>
     <tr>
     <td>Are you regular visitor of RoseIndia.net</td>
     <td><input type="checkbox" name="check"></td>
     </tr>
     <tr>
     <td>Nationality</td>
     <td><select name="nationality" size="1">
     <option>India</option>
     <option>USA</option>
     <option>UK</option>
     <option>SRI LANKA</option>
     </td>
     </tr>
     <tr>
     <td>Description</td>
     </tr>
     <tr>
     <td><textarea rows="2" name="description" cols="20">
     </textarea></td>
     </tr>
     <tr>
     <td><input type="submit" name="submit" value="submit"></td>
     <td><input type="reset" name="reset" value="reset"></td>
     </tr>
     </form>
     </table>
     </center>
     </body>
     </html>

The html form tag has the attribute action="nextPageToPost.jsp". When we press submit button it is going to request the jsp page nextPageToPost.jsp.
step 2 : Create your Jsp Page
      next step is to create one jsp for handle the request from the user. this jsp page may contain the database connection or your business logic.
For Example : nextPageToPost.jsp

     <html>
     <head><title>JSP Form Post Example</title></head>
     <body>
     <center><table border="2">
     <tr>
     <td><h3>Your message has been posted by using Post Method</h3></td> 
     </tr>
     </center></table>
     <center><table border="2" >
     <tr>
     <td><h4>Name:</h4></td><td><%=request.getParameter("name") %></td> 
     </tr>
     <tr>
     <td><h4>Password:</h4></td><td><%=request.getParameter("name") %></td> 
     </tr>
     <tr>
     <td><h4>Sex:</h4></td><td><%=request.getParameter("sex")%></td> 
     </tr>
     <tr>
     <td><h4>Are you regular <br>visitor of RoseIndia.ne</h4></td><td>
     <% if(request.getParameter("check").equals("on"))out.println("Yes"); %></td> 
     </tr>
     <tr>
     <td><h4>Nationality</h4></td><td><%=request.getParameter("nationality") %>
     </td> 
     </tr>
     <tr>
     <td><h4>Description</h4></td><td><%=request.getParameter("description") %>
     </td> 
     </tr>
     </center></table>
     </body>
     </html>
step 3 : Create your project Folder structure as follows
step 4 : create Deployment descriptor (web.xml) file:
     <?xml version="1.0" encoding="UTF-8"?>
     <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
     http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
     <welcome-file-list>
     <welcome-file>Demo.html</welcome-file>
     </welcome-file-list>
     </web-app>
step 5 : create war file
      open command prompt

     start ->run->cmd

     Goto your project directory (using cd command)

     for example your project is in d:\Jspdemo\Firstprogram then use the following command

     c:\Docu...>d:

     d:\> cd Jspdemo\Firstprogram

     d:\Jspdemo\Firstprogram>jar -cvf demo.jar *.*
step 6 : start tomcat
      open command prompt

     start ->run->cmd

     Change directory To C:\Program Files\Apache Software Foundation\Tomcat 5.0\bin

     set the following paths:

     1. C:\Program Files\....\Tomcat 5.0\bin>set JAVA_HOME="C:\Program Files\Java\jdk1.5.0_01\bin"

     2. C:\Program Files\....\Tomcat 5.0\bin>set CATALINA_HOME="C:\Program Files\Apache Software

     Foundation\Tomcat 5.0\bin"

     start tomcat using following command

     3. C:\Program Files\....\Tomcat 5.0\bin>startup
step 7 : Run your Application
   1. Open any one of the web browser ( example Internet Explorer )

  2. In address bar type

       http://localhost:8080/

  3. select Tomcat Manager and type username & password.

  4. In the bottom of the page , select your war file ( using browse ) and press Deploy Button

  5. finally your war file name comes in the Applications list and select your project and it is automatically runs.

Back to Top
All Rights Reserved : skdotcom technologies