Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request.getParameter() coming as Null in IE

 
Nick Smit
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The hidden input has no value.
 
Nick Smit
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am setting it in javascript. That is what I am trying to retrieve in action.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the JavaScript boofing up in IE?
 
Nick Smit
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How have you checked it? The JavaScript failing is the most obvious problem point.
 
Nick Smit
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have put alert after setting value. It is coming fine.
 
Sergey Baranov
Greenhorn
Posts: 18
C++ Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of IE?
 
Nick Smit
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IE 8
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this point I think you need to post a SSCCE.
 
Nick Smit
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic