• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hidden variables coming as null

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic