Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hidden variables coming as null  RSS feed

 
sameer s
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a hidden variable in JSP and its value is hard coded as specified below.
<input type="hidden" name="hidparam1" value="hidvalue1">
On click of a button in the JSP, the servlet(myservlet1) will be invoked.
I am retriving a value in Servlet like
String param1= request.getParameter("hidparam1");
Some times, the value for "hidparam1" is coming as null in the servlet.
When I give System.out.println(request.getParameter("hidparam1"));
I get null as output.
Please help. This is really urgent.
Thanks and Regards
Sfs
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check that you have the hidden field within form tags. If that doesn't work, try giving a little more info:
Does it sometimes return as non-null? Do you have any javascript? What browser are you using?
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
deadliestofall,
We don't have many rules at Javaranch, but our naming policy is one of them. We would like you to continue posting, but would you please change your display name first?. Thanks.
You can change your display name here.
 
sameer s
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most of the time, it returns non-null values. Sometimes null values are returned but the exact scnario when that happens is not know. The browser is IE. I'm using Javascript in this for form submission. The hidden variable is indeed enclosed in the form.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, the only way you can get a null from getParameter is if the name does not exist in the form. This can be due to a difference in spelling - it is case sensitive.
If this was my problem I would dump all of the parameters from the request to see what was really being tranmitted. You can use getParameterNames to get an Enumeration of all parameter names that are present.
Bill
 
sameer s
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I mentioned, most of the time, I do get the actual value. Its only in some cases that I don't.
I'm using Weblogic 5.1. As I see from the weblogic docs, there is a parameter for reset time for 'Post' parameters and its defaulted to 30 secs. But I believe the null value appears though the response comes back in less that 30 secs.
Can't seem to find out why or how this happens...
Please help....
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't want to sound picky, but did you actually read the naming policy? I'm afraid "javaguy2005" doesn't look much like a real name, either.
Please read and comply with the naming policy. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!