wood burning stoves 2.0*
The moose likes JSP and the fly likes Request.getParameter() coming as Null in IE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Request.getParameter() coming as Null in IE" Watch "Request.getParameter() coming as Null in IE" New topic
Author

Request.getParameter() coming as Null in IE

Nick Smit
Greenhorn

Joined: Feb 08, 2011
Posts: 19
Using Struts 1.3

My code
In JSP setting hidden fields like this
-------------
<input type="hidden" name="myStatus"/>
-------------
Setting values and Submitting form in JS
-------------
document.getElementsByName("myStatus")[0].value = 10;
document.forms[0].action = "/corporate/user/viewSheet";
document.forms[0].submit();
-------------

Retrieving in Action
-------------
System.out.println(request.getParameter("myStatus"));

-------------

I am getting proper value in Chrome and Firefox but in IE this comes as Null

Anybody has a solution?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60808
    
  65

The hidden input has no value.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nick Smit
Greenhorn

Joined: Feb 08, 2011
Posts: 19
I am setting it in javascript. That is what I am trying to retrieve in action.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60808
    
  65

Is the JavaScript boofing up in IE?
Nick Smit
Greenhorn

Joined: Feb 08, 2011
Posts: 19
I have checked it goes and sets it properly in javascript but when it comes in action, it gives me null. remember its working perfectly in other browsers.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60808
    
  65

How have you checked it? The JavaScript failing is the most obvious problem point.
Nick Smit
Greenhorn

Joined: Feb 08, 2011
Posts: 19
I have put alert after setting value. It is coming fine.
Sergey Baranov
Greenhorn

Joined: Aug 27, 2005
Posts: 18

What version of IE?


Sergey Baranov
Nick Smit
Greenhorn

Joined: Feb 08, 2011
Posts: 19
IE 8
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60808
    
  65

At this point I think you need to post a SSCCE.
Nick Smit
Greenhorn

Joined: Feb 08, 2011
Posts: 19
Finally I found what is the issue.

My Hidden field has name "myStatus"

My page is consisting of mutiple JSPs
In other jsp, I had one more input field which has same id "myStatus"

IE was referring to that field so I was not getting value, while other browsers can differentiate between id and name, IE is dumb not to do that. So when I changed the name of my hidden field , it started working...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request.getParameter() coming as Null in IE
 
Similar Threads
Retaining selected value in combo box after refresh
Query String Problem
Good use of JSP for populating textfields
need caching
need help dependent dropdown list