0% found this document useful (0 votes)
27 views

Program: Form1serv - Java

This document contains code for a Java servlet program that: 1) Retrieves form parameter values submitted from an HTML form; 2) Generates an HTML page displaying the parameter values; 3) The HTML form collects and submits student information like name, address, etc; 4) The servlet retrieves and displays this information on the response page.

Uploaded by

Janani Shree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Program: Form1serv - Java

This document contains code for a Java servlet program that: 1) Retrieves form parameter values submitted from an HTML form; 2) Generates an HTML page displaying the parameter values; 3) The HTML form collects and submits student information like name, address, etc; 4) The servlet retrieves and displays this information on the response page.

Uploaded by

Janani Shree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

PROGRAM

form1serv.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class form1serv extends HttpServlet
{
protected void processRequest(HttpServletRequest request,HttpServletResponse
response) throws ServletException,IOException
{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
try
{
out.println("<html>");
out.println("<head>");
out.println("<title>servlet form servlet</title>");
out.println("</head>");
out.println("<body>");

out.println("<h1>first name:"+request.getParameter("fname")+"</h1><br>");
out.println("<h1>last name:"+request.getParameter("lname")+"</h1><br>");
out.println("<h1>address:"+request.getParameter("address")+"</h1><br>");
out.println("<h1>branch:"+request.getParameter("branch")+"</h1><br>");

out.println("<h1>email:"+request.getParameter("email")+"</h1><br>");
out.println("<h1>mobile:"+request.getParameter("mobile")+"</h1><br>");
out.println("</body>");
out.println("</html>");
}
finally
{
out.close();
}
}
protected void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
processRequest(request,response);
}
protected void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
processRequest(request,response);
}
}
form1html.html
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" Content="text\html" charset="UTF-8">
</head>

<FORM name ='postparm'


method="post"action="http://127.0.0.1:8080/examples/servlet/form1serv">
<h1>Post Student Information</h1><br>
<table>
<tr>
<td><B>First Name</B></td>
<td><input type="text" name="fname" size="25" value=""></td></tr>
<tr><td><B>Last Name</B></td>
<td><input type="text" name="lname" size="25" value=""></td></tr>
<tr><td><B>Address</B></td>
<td><input type="text" name="address" size="25" value=""></td></tr>
<tr><td><B>Branch</B></td>
<td><input type="text" name="branch" size="25" value=""></td></tr>
<tr><td><B>Email</B></td>
<td><input type="text" name="email" size="25" value=""></td></tr>
<tr><td><B>Mobile</B></td>
<td><input type="text" name="mobile" size="25" value=""></td></tr>
</table>
<input type="Submit" value="Submit">
</Form>
</html>

OUTPUT

You might also like