Java Guy wrote:

> Is there something similar to jsp:setProperty is the servlet API?  I'm
> trying to implement a "Model 2" application.  The "Submit" button on a (jsp
> generated) HTML page sends the contents of the form to a servlet, which,
> after processing the contents, forwards the request to a JSP page which
> displays the results.)  In order to facilitate the processing of the data by
> the servlet, I'd like a way to automatically get all the data that was
> submitted by the form to be available in a bean, instead of getting each
> attribute seperately in the servlet.
>
> If it were a jsp only solution,
> <jsp:setProperty name="mybean" property="*" />
>
> at the top of the .jsp would do the trick.
>

There is nothing like this in the standard servlet API.  However, you could build a
utility method that did this for you.  It could accept a JavaBean instance and your
current HttpServletRequest as arguments, use the Java Reflection API to introspect
the property names supported by that bean, and do the appropriate assignments based
on the parameters included in the request.

Because this process is so similar to what a JSP engine does for the servlet
generated by your JSP pages, it might be possible to look at the source code for an
existing JSP engine implementation (such as Jakarta's Tomcat at
<http://jakarta.apache.org>), extract the code that does this for that
implementation, and use it as a starting point for your utility class.

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to