>I deal with this kind of thing in a very similar manner, using the
following
>approach:
>
>* Define a bean whose properties are all of the entry fields on a
form.
>* In a servlet, create this bean with default values and stuff it in
the
>session
>* Forward control to the JSP page, which is programmed to use the
current
>  values in the bean as the data in the input fields (using the
<DISPLAY> tag
>  to grab them).
>* User fills out the form and submits to a servlet, which does the
validation.
>* In addition to validation, the servlet updates the bean properties
to reflect
>
>  the last values entered by the user.
>* If the servlet discovers a problem, create an error message bean
with some
>  sort of message describing the problem, and stash it in the
request (so you
>  don't have to worry about cleaning it up later).
>* Then, forward control back to the JSP page with the original input
form.
>* Include some conditional logic (in my case it's at the top of the
page) to
>  extract and display the error text.  Something like:
>    <excludeif property="errorbean:message" match="null">
>    <display property="errorbean:message">
>    </excludeif>
>* When the JSP page displays the form again, it will grab the
original bean's
>  values, which now contain whatever he/she entered last time.

Craig, thanks for the quick response.  I really like your solution.

Now assume I ignore your advice about defining a bean (whose
properties are all of the entry fields on a form) and forwarding it
to initialize the JSP entry form.

The first time the JSP page is accessed by the user (when there is no
error), does the servlet have to create an "empty" error bean (with a
null  message property) and pass that to the JSP file?  What if the
user just bookmarks the JSP URL and circumvents the servlet forward?

After reading the JSP .92 spec, it seems to imply that if an
bean is not supplied to a JSP, the JSP will just create a new one
automatically.  I suppose if the error bean defaults to a null
message, this is fine, but it still seems like a waste.

D J


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to