-none- 2007-09-04 - By Frank W. Zammetti
Back Oh, you know what, my bad... I'm on vacation this week and my brain is shut down even more than some would say it normally is... you asked about Struts2, and I answered for Struts1. Sorry about that, ignore what I said.
For S2, let's say you have a String property "name" on your HelloWorldAction class, you can use:
<s:property value="name"/>
...in your JSP to display it. You'll also need:
<%@(protected) prefix="s" uri="/struts-tags" %>
...to make that work. And of course, make sure you have an appropriate getter method on the Action too.
Frank
-- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM/Yahoo: fzammetti MSN: fzammetti@(protected) Author of "Practical Ajax Projects With Java Technology" (2006, Apress, ISBN 1-59059-695-1) and "JavaScript, DOM Scripting and Ajax Projects" (2007, Apress, ISBN 1-59059-816-4) Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it!
REMIJAN, MICHAEL J [AG/1000] wrote: > So if I have "helloworld.action" defined as: > > <action name="helloworld" class="test.struts.HelloWorldAction"> > <result>/WEB-INF/jsp/helloworld.jsp</result> > </action> > > Then I can retrieve the object with: > > MyActionForm form = (MyActionForm)request.getAttribute("helloworld"); > > ?? > > > -- --Original Message-- -- > From: Frank W. Zammetti [mailto:fzlists@(protected)] > Sent: Tuesday, September 04, 2007 8:31 AM > To: Struts Users Mailing List > Subject: Re: How to access the ActionForm in a JSP? > > You can find the form as a request attribute with the same name you used > > in your config file, so: > > MyActionForm form = (MyActionForm)request.getAttribute("myFormName"); > > Frank > > -- > Frank W. Zammetti > Founder and Chief Software Architect > Omnytex Technologies > http://www.omnytex.com > AIM/Yahoo: fzammetti > MSN: fzammetti@(protected) > Author of "Practical Ajax Projects With Java Technology" > (2006, Apress, ISBN 1-59059-695-1) > and "JavaScript, DOM Scripting and Ajax Projects" > (2007, Apress, ISBN 1-59059-816-4) > Java Web Parts - http://javawebparts.sourceforge.net > Supplying the wheel, so you don't have to reinvent it! > > REMIJAN, MICHAEL J [AG/1000] wrote: >> Newbie question here. Suppose I have action, "helloworld.action" > which >> I use to grab a bunch of data I wish to display on a JSP page. My >> question is how do get a reference to that action object in the JSP >> page? The tutorials on the Struts2 website showed examples using > <form >> /> tags, but I don't need to use <form /> tags. I just want to > display >> data. >> >> Michael J. Remijan >> >> >> > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- > -- ---- ---- ---- ---- ---- ----- >> This e-mail message may contain privileged and/or confidential > information, and is intended to be received only by persons entitled to > receive such information. If you have received this e-mail in error, > please notify the sender immediately. Please delete it and all > attachments from any servers, hard drives or any other media. Other use > of this e-mail by you is strictly prohibited. >> >> All e-mails and attachments sent and received are subject to > monitoring, reading and archival by Monsanto. The recipient of this > e-mail is solely responsible for checking for the presence of "Viruses" > or other "Malware". Monsanto accepts no liability for any damage caused > by any such code transmitted by or accompanying this e-mail or any > attachment. > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- > -- ---- ---- ---- ---- ---- ----- >> >> >> >> > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- >> No virus found in this incoming message. >> Checked by AVG Free Edition. >> Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: > 9/3/2007 9:31 AM > > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ > To unsubscribe, e-mail: user-unsubscribe@(protected) > For additional commands, e-mail: user-help@(protected) > > > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- ---- ---- ---- ---- ----- > This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited. > > > All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware". Monsanto accepts no liability for any damage caused by any such code transmitted by or accompanying this e-mail or any attachment. > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- ---- ---- ---- ---- ----- > > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ > To unsubscribe, e-mail: user-unsubscribe@(protected) > For additional commands, e-mail: user-help@(protected) > > > > >
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ To unsubscribe, e-mail: user-unsubscribe@(protected) For additional commands, e-mail: user-help@(protected)
|
|