wood burning stoves 2.0*
The moose likes Servlets and the fly likes Creating Table, Accessing table values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Creating Table, Accessing table values" Watch "Creating Table, Accessing table values" New topic
Author

Creating Table, Accessing table values

Anita Karnati
Greenhorn

Joined: Dec 26, 2000
Posts: 6
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

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Dec 26, 2000
Posts: 6
Hi
Thanks for sending me code
 
Consider Paul's rocket mass heater.
 
subject: Creating Table, Accessing table values
 
Similar Threads
Need help in find the text from 1000 Records
HTML elements name
Hibernate equivalent of MetaData
java data structures
help with getting the table name from the user input