This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes Retain textbox values after redirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Retain textbox values after redirect" Watch "Retain textbox values after redirect" New topic
Author

Retain textbox values after redirect

Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 136
Hi,

in my webapp i have a condition that on button click the data in a textbox should be assigned with the user name and should be posted to database, and it should be redirected back, here i'm unable to have the value in textbox, but if i click the back button it is there. please help me with this.

Below are the screens showing it

in the third screen i'm getting it if i hit a back button and if i hit redirect to home it will trigger a query that is on that page. i want to go to previous page automatically. please help me with it.

i want something that acts like a browsers back button

Thanks



[Thumbnail for untitled1.JPG]


[Thumbnail for posting.JPG]


[Thumbnail for back.JPG]

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

I think you need to keep the submitted value in request scope and get the value again from request in an appropriate field/text box.
Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 136
thanks for the reply. but sorry, i didn't get it. could you please elaborate it?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

1. you are entering say "xyz" in text box - which has name = "userInput"

2. now you are submitting to servlet(for example), there you are getting value as
String txtBoxVal = request.getParameter("userInput"); then you are inserting txtBoxVal to DB right?

3. then, if you forward again to first/form jsp = >
then set the txtBoxVal to request attribute in servlet

or, if you redirect then place the value as querystring.

4. now you get the value from appropriate place(param or attribute), then show as a value of the textbox
as in value='${param.txtBoxVal }' or value='${"txtBoxVal"}'
Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 136
no here actually the textbox value is getting pulled from the database, and once the button is clicked the the alloc column should be added with the logged in user name for the corresponding row(textbox value) in the database i.e. here post operation is being done and in the home page there is a query to fetch the data with user name as null into the textbox. so, when i click the button the post should be done and the text in textbox should be the previous text. only when user clicks in the link 'home', new data is to be fetched from the database.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retain textbox values after redirect