File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes request.getParameterValues not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "request.getParameterValues not working" Watch "request.getParameterValues not working" New topic
Author

request.getParameterValues not working

rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
Hi all,
I have checkboxes in my JSP and I am just trying to get their values in my java code



My java code


im getting null

please clarify

Thanks
Rajesh
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

from the HttpServletRequest API

Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.


change your form to use get to send the data so that you can check what is being sent to the servlet in the url bar.

Also if you use firefox, you can use an addon called Firebug that will help you choose this.

Sean


I love this place!
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
Using get method is not safe for more sensitive data
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
in form i have as this code for email functionality so it needs to be have post method with enctype.


please let me know other options
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
If this was my problem I would use Firefox addons to examine exact contents of the HTML page and the exact contents of the request like Sean Clark said.

You will be amazed at how easy it is to debug problems like this when you can see exactly what is being sent.

Bill
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

rajeshkannan sella wrote:Using get method is not safe for more sensitive data

It is a myth that POST is "more secure" than GET. Neither is secure.
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
As suggested i made it as "get"



im getting the following exception
org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:299)
at com.sa.ldg.controller.actions.SysAgenciesAlertsScreenAction.execute(SysAgenciesAlertsScreenAction.java:73)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.sa.ldg.config.SessionFilterServlet.doFilter(SessionFilterServlet.java:69)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)


Let me know how to proceed solving this
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

I don't think you can do a GET with the data that you are trying to send.
But as I said, use Firefox along with the firebug plugin, this will allow you to see all the parameters that are being send to your application through the post.

Also you may wish to post the whole form.

Sean
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
i have installed the plugin but dont have any idea to how to see the parameters send.
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
For multipart form data Oreilys MultipartParser class will get you the parameters



Thanks
Rajesh
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
I got a new problem, Now im not able to use both MultipartParser and DiskFileUpload to get the form fields im getting exception java.io.IOException: Corrupt form data: premature ending



please help me
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
You can only parse through the request once .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.getParameterValues not working