Here is my simple code
Html file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>A Sample FORM using POST</TITLE>
</HEAD>
<BODY BGCOLOR="#FDF5E6">
<H1 ALIGN="CENTER">A Sample FORM using POST</H1>
<FORM ACTION="test" METHOD="POST" name=samp>
Name:
<INPUT TYPE="TEXT" NAME="name"><BR>
<INPUT TYPE="SUBMIT" VALUE="Submit Order">
</FORM>
</BODY>
</HTML>
SERVLET
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class
test extends HttpServlet
{
public void doPost(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
String para = req.getParameter("name");
ServletOutputStream out = res.getOutputStream();
// set content type and other response header fields first
res.setContentType("text/html");
// then write the data of the response
out.println("<HEAD><TITLE> Testing </TITLE></HEAD><BODY>");
out.println("<h1> "+para+"</h1><br>");
}
}