aspose file tools*
The moose likes JSP and the fly likes How to retain textbox value after refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to retain textbox value after refresh" Watch "How to retain textbox value after refresh" New topic
Author

How to retain textbox value after refresh

smee bond
Ranch Hand

Joined: Sep 29, 2007
Posts: 34
I have a simple jsp page where I have a textbox. When I enter some data in the textbox and hit 'refresh', the data disappears. Is there a way to retain the textbox data either in jsp/html after refresh? please help!

Thank you.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

HTML textboxes have a "value" property.

<input type="text" name="firstName" value="smee" />


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jeff Rummings
Ranch Hand

Joined: Dec 20, 2007
Posts: 42
If refresh re-submits the form, then yes. You can use the value attribute to retain input's value. For example,

smee bond
Ranch Hand

Joined: Sep 29, 2007
Posts: 34
Sorry for not providing the complete details about the problem. Here is the situation:

I have a parent window (not a form, just a plain parent.html) where I have a link (<a href="" />)from which I am opening a child window (child.jsp form). I have a few check boxes on the child. When I select the checkboxes and press submit on child window, the selected values are sent and populated in <textarea /> of parent.html through javascript. Till this point it works fine.
But when I go back to the parent window and press refresh/click on the link to open child window, the value <textarea /> is gone! How do I retain this value? please help. thank you!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

<textarea>${ someValue }</textarea>


GenRocket - Experts at Building Test Data
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can't with your current approach.

If the amount of data in the checkboxes is small, instead of setting the values using Javascript directly, use Javascript to refresh the window with the values in the querystring.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to retain textbox value after refresh