The following reply was made to PR mod_jserv/5361; it has been noted by GNATS.
From: vsolve apache <[EMAIL PROTECTED]> To: [EMAIL PROTECTED], [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: mod_jserv/5361: ServletRequest.getParameterValues() method does not return multiple values Date: Fri, 26 Nov 1999 06:30:01 -0800 (PST) Hi, There is no problem with JServ. In your program, do like this: ... ... String vals[] = req.getParameterValues("movieid"); ... And do array access like vals[0],vals[1],... you will get all the values. regards, vsolve_apache visolve dot com --- Mohan Amasa <[EMAIL PROTECTED]> wrote: > Hi, > I appreciate your help on this. I am not clear on > one > important aspect of your reply. You did not mention > if > there is a problem with JServ? Or if I am doing > something incorrect. It sounds like you suggested a > work around. Could you please clarify that. Of > course, > the work around will work. But, I need to make > significant changes in Java, as I used the > getParameterValues() many places, with the > assumption > that it returns multiple values for a single > parameter > name. Please correct me if I am wrong. > > Thnaks again, > Mohan Amasa > > --- vsolve apache <[EMAIL PROTECTED]> wrote: > > Hi, > > > > In your Html file use hidden type of inputs to > pass > > the values to server.As well as you should use > > different names in 'name' parameter(eg. movieid) > in > > checkbox type inputs. > > > > And in your servlet program use > getParameterNames() > > function to get the all the names which are used > in > > input name of your html file.(No need to use > > getReader() function). getParameterNames() values > > should be assigned to Enumeration type > variable.This > > consists of all values along with names. To get > the > > values alone use getParameterValues("xxx") within > > loop. > > > > Here the sample html and servlet programs for > you. > > Its working fine. > > > > sample.html > > ---------------- > > > > <html><head><title>Sample</title></head> <body> > > <form action=/example/sample method=POST> > > <input type=hidden name=sample > value=sample> > > <BR>Java<input type=checkbox name=ide > > value=Java> > > <BR>JavaApplets<input type=checkbox > > name=ide1 > > value=JavaApplets> > > <BR>JaveServlets<input type=checkbox > > name=ide2 > > value=JavaServlets> > > <BR><BR><input type=submit><input > type=reset> > > > > </form> </body></html> > > > > ***************************** > > > > sample.java > > --------------- > > > > import java.io.*; > > import javax.servlet.*; > > import javax.servlet.http.*; > > import java.util.*; > > > > public class sample extends HttpServlet > > { > > public void doPost(HttpServletRequest req, > > HttpServletResponse res) > > throws ServletException, IOException > > { > > //set the "content type" header of the > > response > > res.setContentType("text/html"); > > > > //Get the response's PrintWriter to return text > to > > the client. > > PrintWriter toClient = > res.getWriter(); > > Enumeration values = > > req.getParameterNames(); > > while(values.hasMoreElements()) { > > String name = > > (String)values.nextElement(); > > String value = req.getParameterValues(name)[0]; > > if(name.compareTo("submit") != 0) > { > > toClient.println("<p>"+name+": > > "+value); > > } > > } > > // Close the writer; the response is done. > > toClient.close(); > > } > > } > > > > All the best and Njoy with servlets. > > > > > > regards, > > > > vsolve_apache > > visolve dot com. > > > > > > > > > > > > >Number: 5361 > > >Category: mod_jserv > > >Synopsis: > ServletRequest.getParameterValues() > > method does not return multiple values > > >Confidential: no > > >Severity: serious > > >Priority: medium > > >Responsible: jserv > > >State: open > > >Class: sw-bug > > >Submitter-Id: apache > > >Arrival-Date: Wed Nov 24 11:10:01 PST 1999 > > >Last-Modified: > > >Originator: [EMAIL PROTECTED] > > >Organization: > > apache > > >Release: > > > Apache=apache-1.3.6-7;JServ=ApacheJServ-1.1-b2_RH6X > > >Environment: > > OS: Red Hat 6.0 > > Java: JDK 1.2 > > >Description: > > When a browser sends a request like the following > > one, > > which is captured using getReader() method. > > > > > movieid=430&movieid=752&movieid=25&movieid=437&movieid=436&movieid=429&movieid=465&movieid=432&movieid=107&movieid=273&link=1.117.118.120 > > > > > > When I called > > ServletRequest.getParameterValues("movieid"), I an > > array with > > only one value 430. I do not get all the values > into > > the array. > > I know when I call > > ServletRequest.getParameterValue("movieid"), I get > > one > > value. > > But the ServletRequest.getParameterValues, note > the > > s > > at the end, should give > > me all the values packaged into the array. > > Request: > > I am developing a serious Web site. I will be very > > thankful someone helping me on this. > > > > Regards > > Mohan > > >How-To-Repeat: > > <html> > > <head> > > <SCRIPT language="JavaScript1.2"> > > <!-- > > function CheckAll(val) > > { > > frm = document.movieresults; > > for (var i=0;i<frm.elements.length;i++){ > > var e = frm.elements[i]; > > e.checked = val; > > } > > } > > > > function doSubmit(handler){ > > frm=document.movieresults; > > frm.link.value=handler; > > frm.submit(); > > } > > --> > > </script> > > <title>Results</title> > > </head> > > <body > > > > > <TABLE cellpadding=6 cellspacing=5 border=0> > > <TH><H3> > === message truncated === __________________________________________________ Do You Yahoo!? Thousands of Stores. Millions of Products. All in one place. Yahoo! Shopping: http://shopping.yahoo.com