This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes A basic question about Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "A basic question about "request"" Watch "A basic question about "request"" New topic
Author

A basic question about "request"

Allan Wang
Greenhorn

Joined: Apr 23, 2001
Posts: 20
I was very confused about using "requset" in jsp/servlet program. I think the parameter/values of hidden input field in a form will everytime be submitted to my servlet. But when I press the back button and then submit, in my servlet I get the parameter values which is belong to the page before I push back button. In these two pages, there are the same input field. Who can give me an clarification or some advice or a link?
Thanks very much.
Mahesh Rana
Ranch Hand

Joined: Sep 05, 2001
Posts: 139
The veriables get cached while you switch between the pages.
Simple solution for this problem is write some code for body onLoad which will initialize the variables everytime you load the page.
Another solution is dont let browser cache that page.
You can do it by --
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "Thu, 26 Sep 1974 06:00:00 GMT");
regards.


SCJP2
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: A basic question about "request"
 
Similar Threads
saving an input element state(value)
request.getParameter is returning null value
Why the form hidden field values can't be passed into servlet?
jQuery load with Callback
CastMap getTrimmedString() error?