Yes, this actually happens by default if the form bean associated with a JSP
already has data.  So, if you have an ActionForm named "myActionForm" with a
field "userName", and "userName" has a value, then the Struts tag below will
render the text input with that value already in it.

<html:text name="myActionForm" property="userName" />

Similarly, whatever value is specified for the property in an <html:select>
tag will determine what value is pre-selected in the drop-down when the page
is rendered.

Actually, if you forward right back to the page the submit occurred from,
the form bean should still be in the request and this should happen
'automatically'.  If you have an intermediate page, or a redirect Action, or
anything that causes the request to be terminated, you'll have to either
stuff the form bean into the (new) request or the session before forwarding
back to the page.

-----Original Message-----
From: I-Sampige, Srinivas [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 23, 2002 12:01 PM
To: Strutsuser (E-mail)
Subject: populating JSP from


Does anybody know if it is possible to populate  a form in a JSP with data
from a formbean ?(reverse to what happens when the form gets submitted to an
action). What I am trying to do is,... when user enters some data data on a
screen(JSP) and submits to an action...&. if there is an error in the
action(something like record not found in database) then I want to show the
same screen(JSP) to the user with along with the data he originally he keyed
in. I can do this with scriplet code in the JSP but I want to use a cleaner
way because we are following a consistent approach of not puttinng java code
in our JSPs in our project.

thanks in advance
Srinivas

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to