File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes request.getQueryString() returning null? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "request.getQueryString() returning null?" Watch "request.getQueryString() returning null?" New topic
Author

request.getQueryString() returning null?

Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Does anyone know why request.getQueryString() would return a null, even when I am posting? Here's the deal....I'm trying to prevent my users from posting again using the refresh button on the right click of the mouse button. By getting the query string off of the request, I can determine if the request was already submitted, however I can't seem to get anything but a null using the "request.getQueryString()"?
P.S. I'm using J2EE. Version 3.5.3.
Thanks!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Since there's no query string on a post (the parameter data is sent as part of the body), it's not surprising you are not getting anything.
But backing up a bit, I'm not sure that your technique for detecting multiple posts via refresh is sound. This very topic has been discussed a number of times in the past, and a quick search though this (and perhaps the Servlets forum) will point you in the right direction.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
So when my user updates an input field and hits the update button, it works fine. However, if they hit the update button, the input fields are disabled on post if the values have not been updated. But let's say they walk away from their computer for just a "second" and come back to hit the refresh button. The data gets submitted again even though no changes have been made.
Just out of curiosity, how do you get the parameters from the body of the form or is there a way?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

You don't have to worry about how the parameters are passed to the request, the request.getParameter() method hides any differences between get and post operations.
With regards to detecting when a post is re-submitted as a result of a refresh, did you look for previous topics on this subject? There's good information for you there.
bear
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Ok, thanks. I will search for topics regarding "when a post is re-submitted as a result of a refresh".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.getQueryString() returning null?
 
Similar Threads
how to bring variable from previous session to next session
Getting the query string in included and forwared servlet or page
getRemoteUser is always anonymous
Problem with request.getParameter
httpServlet returns anonymous