Re: Filling-in a Bean inside a Servlet

Chris Pratt <[email protected]> Sat, 3 Sep 2005 00:08:09 -0700
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
------=_Part_1843_26852514.1125731289498
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Although I haven't used it extensively. I believe Struts has a method or=20
doing something similar.
 (*Chris*)

 On 9/2/05, Zerbe John W <[email protected]> wrote:=20
>=20
> Hi,
> An alternative would be to do what the jsp processor does. Write your own=
=20
> piece of code that uses reflection to determine what "setters" exist for =
the=20
> bean and match those up with the request parameter names.
> If you do some searching, you may find some free open source that does=20
> this already.
> John Zerbe
>=20
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[email protected]]On Behalf Of Dani
> Pardo
> Sent: Friday, September 02, 2005 12:53 PM
> To: [email protected]
> Subject: Re: Filling-in a Bean inside a Servlet
>=20
>=20
> > Can I fill all the properties of the Bean magically on a line, The
> > same way that the jsp does it via <jsp:setProperty property=3D"*"> ???
> > There must be a trick or a workaround, because this method doesn't
> > scale. There must be some trick to achieve to get a Customer object as =
a
> > parameter:
>=20
>=20
> Hi, I respond to myself.
> I've done intensing search and I've finally get on the conclusion that
> it can't be done:
> When using Servlets and JSPs, you play with FORM parameters on the jsp
> side, and play with attaching attributes on the Servlet side. Acutally,
> it's almost the same I've been doing with Perl CGIs and Template Toolkit.
>=20
> To do the magic-bean-populating trick, you have to use some esoteric
> framwork like Struts:
>=20
> From http://www.coreservlets.com/Apache-Struts-Tutorial/
>=20
> "With Struts, the normal processing flow is that a form submits data to
> a URL of the form blah.do. That address is mapped by struts-config.xml
> to an Action object, whose execute method handles the request. One of
> the arguments to execute is a form bean that is automatically created
> and whose properties are automatically populated with the incoming form
> data. The Action object then invokes business logic and data-access
> logic, placing the results in normal beans stored in request, session,
> or application scope."
>=20
>=20
> --
> Dani Pardo, [email protected]
> Enplater S.A
>=20
>=20
> _________________________________________________________________________=
__
> To unsubscribe, send email to [email protected] and include in the=20
> body
> of the message "signoff SERVLET-INTEREST".
>=20
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>=20
> The information contained in this e-mail may be confidential and is=20
> intended solely for the use of the named addressee.
> Access, copying or re-use of the e-mail or any information contained=20
> therein by any other person is not authorized.
> If you are not the intended recipient please notify us immediately by=20
> returning the e-mail to the originator.(16b)
>=20
>=20
> _________________________________________________________________________=
__
> To unsubscribe, send email to [email protected] and include in the=20
> body
> of the message "signoff SERVLET-INTEREST".
>=20
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html


------=_Part_1843_26852514.1125731289498
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<div>Although I haven't used it extensively.&nbsp; I believe Struts has a m=
ethod or doing something similar.</div>
<div>&nbsp; (*Chris*)<br><br>&nbsp;</div>
<div><span class=3D"gmail_quote">On 9/2/05, <b class=3D"gmail_sendername">Z=
erbe John W</b> &lt;<a href=3D"mailto:[email protected]">zerbe.jw@mellon.=
com</a>&gt; wrote:</span>
<blockquote class=3D"gmail_quote" style=3D"PADDING-LEFT: 1ex; MARGIN: 0px 0=
px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi,<br>An alternative would be t=
o do what the jsp processor does. Write your own piece of code that uses re=
flection to determine what &quot;setters&quot; exist for the bean and match=
 those up with the request parameter names.
<br>If you do some searching, you may find some free open source that does =
this already.<br>John Zerbe<br><br>-----Original Message-----<br>From: A ma=
iling list for discussion about Sun Microsystem's Java Servlet<br>API Techn=
ology. [mailto:
<a href=3D"mailto:[email protected]">[email protected].=
COM</a>]On Behalf Of Dani<br>Pardo<br>Sent: Friday, September 02, 2005 12:5=
3 PM<br>To: <a href=3D"mailto:[email protected]">SERVLET-INTERE=
[email protected]
</a><br>Subject: Re: Filling-in a Bean inside a Servlet<br><br><br>&gt;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Can I fill all the properties =
of the Bean magically on a line, The<br>&gt; same way that the jsp does it =
via &lt;jsp:setProperty property=3D&quot;*&quot;&gt; ???
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; There must be a tr=
ick or a workaround, because this method doesn't<br>&gt; scale. There must =
be some trick to achieve to get a Customer object as a<br>&gt; parameter:<b=
r><br><br>Hi, I respond to myself.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I've done intensing search and I've fi=
nally get on the conclusion that<br>it can't be done:<br>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp; When using Servlets and JSPs, you play with FORM paramet=
ers on the jsp<br>side, and play with attaching attributes on the Servlet s=
ide. Acutally,
<br>it's almost the same I've been doing with Perl CGIs and Template Toolki=
t.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; To do the magic-bean-populat=
ing trick, you have to use some esoteric<br>framwork like Struts:<br><br>Fr=
om <a href=3D"http://www.coreservlets.com/Apache-Struts-Tutorial/">
http://www.coreservlets.com/Apache-Struts-Tutorial/</a><br><br>&quot;With S=
truts, the normal processing flow is that a form submits data to<br>a URL o=
f the form blah.do. That address is mapped by struts-config.xml<br>to an Ac=
tion object, whose execute method handles the request. One of
<br>the arguments to execute is a form bean that is automatically created<b=
r>and whose properties are automatically populated with the incoming form<b=
r>data. The Action object then invokes business logic and data-access<br>
logic, placing the results in normal beans stored in request, session,<br>o=
r application scope.&quot;<br><br><br>--<br>Dani Pardo, <a href=3D"mailto:d=
[email protected]">[email protected]</a><br>Enplater S.A<br><br>____________=
_______________________________________________________________
<br>To unsubscribe, send email to <a href=3D"mailto:[email protected]">=
[email protected]</a> and include in the body<br>of the message &quot;s=
ignoff SERVLET-INTEREST&quot;.<br><br>Archives: <a href=3D"http://archives.=
java.sun.com/archives/servlet-interest.html">
http://archives.java.sun.com/archives/servlet-interest.html</a><br>Resource=
s: <a href=3D"http://java.sun.com/products/servlet/external-resources.html"=
>http://java.sun.com/products/servlet/external-resources.html</a><br>LISTSE=
RV Help:=20
<a href=3D"http://www.lsoft.com/manuals/user/user.html">http://www.lsoft.co=
m/manuals/user/user.html</a><br><br>The information contained in this e-mai=
l may be confidential and is intended solely for the use of the named addre=
ssee.
<br>Access, copying or re-use of the e-mail or any information contained th=
erein by any other person is not authorized.<br>If you are not the intended=
 recipient please notify us immediately by returning the e-mail to the orig=
inator.(16b)
<br><br>___________________________________________________________________=
________<br>To unsubscribe, send email to <a href=3D"mailto:[email protected]=
un.com">[email protected]</a> and include in the body<br>of the message=
 &quot;signoff SERVLET-INTEREST&quot;.
<br><br>Archives: <a href=3D"http://archives.java.sun.com/archives/servlet-=
interest.html">http://archives.java.sun.com/archives/servlet-interest.html<=
/a><br>Resources: <a href=3D"http://java.sun.com/products/servlet/external-=
resources.html">
http://java.sun.com/products/servlet/external-resources.html</a><br>LISTSER=
V Help: <a href=3D"http://www.lsoft.com/manuals/user/user.html">http://www.=
lsoft.com/manuals/user/user.html</a><br></blockquote></div><br>
___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".
<p>
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
<p>

------=_Part_1843_26852514.1125731289498--