• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating Table, Accessing table values

 
Anita Karnati
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How do i create an table that accept 5 user names and their sir names as an input parameters.do i need to give saperate fieldname for all these 10 input fields.
How do i catch these fileds in Servlet, do i need to use Enumeration for this.
Thanks
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need not have to give seperate field names. All can be given same field name and use getParameterValues("fieldName") of the Request object. This will return a String[] with field values entered by user in the same order.
Ravi.
You can test using the following example.
Html form:
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM action="http://localhost:8080/servlet/Handle" method="POST">
<INPUT name="name">
<INPUT name="name">
<INPUT name="name">
<INPUT name="name">
<INPUT name="name">
<INPUT name="name">
<INPUT name="name">
<INPUT name="name">
<BUTTON TYPE="SUBMIT"> SUBMIT
</FORM>
</BODY>
</HTML>
servlet:

public class Handle extends HttpServlet {

public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body bgcolor=\"white\">");
out.println("<head>");
out.println("</head>");
out.println("<body>");
String[] params = request.getParameterValues("name");
for (int i =0 ; i < params.length; i++)
{
out.println(params[i]);
}
out.println("</body>");
out.println("</html>");

out.println("</body>");
out.println("</html>");
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doPost(request, response);
}
}
 
Anita Karnati
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks for sending me code
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic