www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsolve apache <vsolve_apa...@yahoo.com>
Subject Re: mod_jserv/5361: ServletRequest.getParameterValues() method does not return multiple values
Date Thu, 25 Nov 1999 13:30:01 GMT
The following reply was made to PR mod_jserv/5361; it has been noted by GNATS.

From: vsolve apache <vsolve_apache@yahoo.com>
To: mohanamasa@yahoo.com, apbugs@hyperreal.org
Cc: apbugs@Apache.Org
Subject: Re: mod_jserv/5361: ServletRequest.getParameterValues() method does not return multiple
values
Date: Thu, 25 Nov 1999 05:29:56 -0800 (PST)

 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:     mohanamasa@yahoo.com
 >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>
 <A HREF = "http://171.16.1.1/servlets/mega  "> Home
 </A>
 </H3></TH>
 <TH><H3>
 <A HREF =
 "http://171.16.1.1/servlets/handler?link=1.10&language=100">Telugu
 Songs</A>
 </H3></TH>
 <TH><H3>
 <A HREF =
 "http://171.16.1.1/servlets/handler?link=1.10&language=101">Hindi
 Songs</A>
 </H3></TH>
 <TH><H3>
 <A HREF =
 "http://171.16.1.1/servlets/handler?link=1.11">Member
 Login</A>
 </H3></TH>
 <TH><H3>
 <A HREF =
 "http://171.16.1.1/servlets/handler?link=1.12">CD
 Manager</A>
 </H3></TH>
 </TABLE>
 <hr>
 <H2 align="center">Results</h2>
 <FORM METHOD=POST NAME=movieresults
 ACTION="http://171.16.1.1/servlets/handler"> 
 <table width="100%" cellpadding=2 cellspacing=1
 border=0 bgcolor=#dcdcdc> 
 <tr bgcolor=#ffffcc> 
 <td align=center width="1%">&nbsp;</td> 
 <td><font face="Arial,Helvetica"size=-1><b>Movie
 Name</b></td> 
 <td><font
 face="Arial,Helvetica"size=-1><b>Actor</b></td> 
 <td><font
 face="Arial,Helvetica"size=-1><b>Actor</b></td> 
 <td><font
 face="Arial,Helvetica"size=-1><b>Director</b></td> 
 </tr> 
 <TRvalign=middle bgcolor="#eeeeee">
 <td align=center>
 <input type=checkbox name="movieid"
 value="430" checked>
 </td>
 <td>
 Aaradhana</td>
 <td>
 A.N.R</td>
 <td>
 Krishna Kummari</td>
 <td>
 </td>
 </TR>
 <TRvalign=middle bgcolor="#eeeeee">
 <td align=center>
 <input type=checkbox name="movieid"
 value="752" checked>
 </td>
 <td>
 Anarkali</td>
 <td>
 A.N.R</td>
 <td>
 Anjali Devi</td>
 <td>
 </td>
 </TR>
 <TRvalign=middle bgcolor="#eeeeee">
 <td align=center>
 <input type=checkbox name="movieid"
 value="25" checked>
 </td>
 <td>
 Annamaya</td>
 <td>
 A.N.R</td>
 <td>
 Ramya Krishna</td>
 <td>
 K.Raghavendrarao</td>
 </TR>
 <TRvalign=middle bgcolor="#eeeeee">
 <td align=center>
 <input type=checkbox name="movieid"
 value="437" checked>
 </td>
 <td>
 Bangaru Babu</td>
 <td>
 A.N.R</td>
 <td>
 Munjulla</td>
 <td>
 </td>
 </TR>
 <TRvalign=middle bgcolor="#eeeeee">
 <td align=center>
 <input type=checkbox name="movieid"
 value="436" checked>
 </td>
 <td>
 Bangaru Kalalu</td>
 <td>
 A.N.R</td>
 <td>
 Vanisree</td>
 <td>
 </td>
 </TR>
 <TRvalign=middle bgcolor="#eeeeee">
 <td align=center>
 <input type=checkbox name="movieid"
 value="429" checked>
 </td>
 <td>
 Bhaarya Bhartalu</td>
 <td>
 A.N.R</td>
 <td>
 Krishna Kummari</td>
 <td>
 </td>
 </TR>
 <TRvalign=middle bgcolor="#eeeeee">
 <td align=center>
 <input type=checkbox name="movieid"
 value="465" checked>
 </td>
 <td>
 Bhakta Thukaram</td>
 <td>
 A.N.R</td>
 <td>
 Anjali Devi</td>
 <td>
 </td>
 </TR>
 <TRvalign=middle bgcolor="#eeeeee">
 <td align=center>
 <input type=checkbox name="movieid"
 value="432" checked>
 </td>
 <td>
 Budhimanthudu</td>
 <td>
 A.N.R</td>
 <td>
 Kanchana</td>
 <td>
 </td>
 </TR>
 <TRvalign=middle bgcolor="#eeeeee">
 <td align=center>
 <input type=checkbox name="movieid"
 value="107" checked>
 </td>
 <td>
 DaddyDaddy</td>
 <td>
 A.N.R</td>
 <td>
 JayaSudha</td>
 <td>
 Kodi Rama Krishna</td>
 </TR>
 <TRvalign=middle bgcolor="#eeeeee">
 <td align=center>
 <input type=checkbox name="movieid"
 value="273" checked>
 </td>
 <td>
 DasaraBullodu</td>
 <td>
 A.N.R</td>
 <td>
 Vanisree</td>
 <td>
 </td>
 </TR>
 <TABLE BORDER="0" CELLPADDING="6"> 
 <TH ALIGN="LEFT"><A
 href="javascript:CheckAll(1)">Select All</a></th> 
 <TH ALIGN="LEFT"><A
 href="javascript:CheckAll(0)">Unselect All</a></th> 
 </TABLE> 
 <TABLE BORDER="0" CELLPADDING="6"> 
 <TH ALIGN="LEFT"><INPUT TYPE="button" name="ViewSongs"
 value="View Songs"
 OnClick=doSubmit("1.117.118.120")></th> 
 <TH ALIGN="LEFT"><INPUT TYPE="button"
 name="ListenSongs" value="Listen Songs"
 OnClick=doSubmit("1.117.118.121")></th> 
 </TABLE> 
 <INPUT type= text name="link">
 </form>
 <hr>P1&nbsp;&nbsp;<a href
 ="http://171.16.1.1/servlets/handler?link=1.117.118.119&page=1">P2</a>&nbsp;&nbsp;<a
 href
 ="http://171.16.1.1/servlets/handler?link=1.117.118.119&page=2">P3</a>&nbsp;&nbsp;</body>
 </body>
 </html>
 
 >Fix:
 None, looks like an obvious fix, as documented by Sun
 JSDK 2.0 specs.
 >Audit-Trail:
 >Unformatted:
 [In order for any reply to be added to the PR
 database, you need]
 [to include <apbugs@Apache.Org> in the Cc line and
 make sure the]
 [subject line starts with the report component and
 number, with ]
 [or without any 'Re:' prefixes (such as
 "general/1098:" or      ]
 ["Re: general/1098:").  If the subject doesn't match
 this       ]
 [pattern, your message will be misfiled and ignored. 
 The       ]
 ["apbugs" address is not added to the Cc line of
 messages from  ]
 [the database automatically because of the potential
 for mail   ]
 [loops.  If you do not include this Cc, your reply may
 be ig-   ]
 [nored unless you are responding to an explicit
 request from a  ]
 [developer.  Reply only with text; DO NOT SEND
 ATTACHMENTS!     ]
 
 
 
 
 __________________________________________________
 Do You Yahoo!?
 Thousands of Stores.  Millions of Products.  All in one place.
 Yahoo! Shopping: http://shopping.yahoo.com

Mime
View raw message