Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retain textbox values after redirect

 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
untitled1.JPG
Initial screen
[Thumbnail for untitled1.JPG]
posting.JPG
on posting(it is successful)
[Thumbnail for posting.JPG]
back.JPG
once i hit back button
[Thumbnail for back.JPG]
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply. but sorry, i didn't get it. could you please elaborate it?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic