• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating Table, Accessing table values

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Thanks for sending me code
 
Watchya got in that poodle gun? Anything for me? Or this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic