Dear all ,
 
I am trying to run following servlet using tomcat . But am unable to do so . Can any one help !
Best Regards
Pramod
 
example.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
 
public class example extends HttpServlet
{
 
 public void init(ServletConfig config)throws ServletException
 {
  super.init(config);
 }
 
 public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
 {
  doPost(req,res);
 }
 
 public void doPost(HttpServletRequest req,HttpServletResponse  res)throws ServletException,IOException
 {
  res.setContentType("text/html");
  PrintWriter out=res.getWriter();
  out.println("<html>");
  out.println("<head><title>example</title></head>");
  out.println("<body>");
  Enumeration parameters=req.getParameterNames();
  String param=null;
  while(parameters.hasMoreElements())
  {
   param=(String)parameters.nextElement();
   out.println("<bold>"+param+":"+req.getParameter(param)+
   "</bold><br>");
  }
  out.println("</body><html>");
  out.close();
 }
 public String getServletInfo()
 {
  return "example information";
 } 
}
 
example.html
<html>
<head>
<title>
example retrieve
</title>
</head>
<body>
<form action=http://localhost:8080/examples/servlet/example method=post>
<table style="height:173px;width:242px">
<tr>
 <td>last name:</td>
 <td><input name="last name" align="left" size="15"></td>
</tr>
<tr>
 <td>first name:</td>
 <td><input align="left" name="first name" size=15>&nbsp;</td>
</tr>
<tr>
 <td>age:</td>
 <td><input align=left name=age size=2>&nbsp;</td>
</tr>
<tr>
 <td>ssn:</td>
 <td><input align=left name=ssn size=11>&nbsp;</td>
</tr>
<tr>
 <td>dob:</td>
 <td><input align=left name=dob size=8>&nbsp;</td>
</tr>
<tr>
 <td>username:</td>
 <td><input align=left name=username size=8>&nbsp;</td>
</tr>
<tr>
 <td>password:</td>
 <td><input align=left name=password size=8 type=password>&nbsp;</td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
<input type="reset" value=reset>
</form>
</body>
</html>

Reply via email to