Create a Form Page Through JSP Without Beans


Here we are going to create a Form page through JSP without using Beans. In this application we create a home page form which is filled in by the user and then the information is sent to the next page. For this application we follow the following steps.

Step 1: Create a web application

First we choose a new web application and then click on the next button.

create a web application.jpg

Step 2: Name and Location

After choosing the web application we provide it a specific name and location for it, then click on the next button.

name and location.jpg

Step 3: Server and Setting

In this step we provide it a specific server and choose Java EE 6 Web application and click next

server.jpg

Step 4: Select Framework

There is no need to choose any frame for this application.

framework.jpg

Step 5: Create New JSP Files

Create two JSP files: form.jsp and display.jsp.

create a new jsp file.jpg

Formhome.jsp

<html>
 <head><title>Create Person</title></head>
  <body bgcolor="cyan">
   <h1>Enter your details</h1>
    <form action="display.jsp" method="post">
     <table>
       <tr><td>First name:</td>
         <td><input type="text" name="firstName" /></td>
        </tr>
        <tr><td>Last name:</td>
         <td><input type="text" name="lastName" /></td>
        </tr>
        <tr><td>Email-id:</td>
         <td><input type="text" name="email" /></td>
        </tr>
        <tr><td>Place of Birth:</td>
        <td><input type="text" name="Placeofbirth" /></td>
        </tr>
        <tr><td>Contact No:</td>
        <td><input type="text" name="cono" /></td>
        </tr>
        <tr><td>Age:</td>
        <td><input type="text" name="age" /></td>
        </tr>
      </table>
      <input type="submit" value="Submit details" />
     </form>
   </body>
</html>

Display.jsp

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

<html>
  <head><title>Display details</title></head>
    <body bgcolor="green">
     <h1>Your details (or, the details you entered!)</h1>
     <table>
       <tr><td>First name:</td><td><c:out value="${param.firstName}"/></td></tr>
       <tr><td>Last name:</td> <td><c:out value="${param.lastName}" /></td></tr>
       <tr><td>Email-id:</td> <td><c:out value="${param.email}" /></td></tr>
       <tr><td>Place of birth:</td> <td><c:out value="${param.Placeofbirth}" /></td></tr>
       <tr><td>Contact no:</td> <td><c:out value="${param.cono}" /></td></tr>
       <tr><td>Age:</td> <td><c:out value="${param.age}" /></td></tr>
      </table>
    </body>
</html>

Compiling and Running the application

After compiling and running the application we will get the following output

Output

FormHome.jsp

 index.jsp.jpg

Display.jsp

display.jsp.jpg


Similar Articles