• 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

request.getParameter is null

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I've transferred a website from a test server to a live one, which seemingly has the exact same set up, but I have one problem.

Whenever a parameter is sent in a URL, e.g.

www.website.com/script.jsp?action=enter

the action parameter isn't picked up.

This

String szAction = null;
szAction = request.getParameter("action");
System.out.println("Action is "+szAction);

results in "Action is null".

It's the same throughout the site since I moved it over. Running on Apache with mod_jk to tomcat 3.2.3

Any idea what the problem could be?
 
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had the same problem. We used to run our applications on eWave web server and then moved to JBoss. All of a sudden some applications did not pick up parameters from URL. A workraround that worked for me was putting URL encoded fields into hidden form fields in the page:

I am not sure why I encountered this problem when moving to JBoss...
 
Paid O'Cuana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, but it's a fairly big app and that would take a long time. Plus, there must be a more satisfactory solution, you have to be able to do URL encoding.

Do you know what causes it? Could I be missing a library of some sort?/
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this, in script.jsp just write:



Replacing 'action' with 'command'. In one application I did, I would get error when I passed parameter called delete, once I renamed it to deleteRecord everything worked fine.
 
Paid O'Cuana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I've set up a test for this on two different servers. Click on the link that appears to view the output.

Server A Test

and

Server B Test

It works on Server B, but breaks down on Server A. You'll notice that request.getParameter gets the correct values from the URL in Server B, but it's null in Server A.
However, request.getQueryString() returns the proper query string in both examples.

Here's the source code used:




I've done a Tomcat re-install, hoping that might solve my problems, but got the same error. Has anyone encountered this problem before?

[ June 14, 2004: Message edited by: Paid O'Cuana ]
[ June 14, 2004: Message edited by: Paid O'Cuana ]
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yup, some of my colleagues had that or a similar problem.
They just used hidden fields or something as a work around, which as you said is not very satisfactory.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic