Hi Mark, I've tried this now, but I'm unable to access the data from the JSP. In the struts.xml configuration file, the action involved is configured this way:
<action name="Search_*" method="{1}" class="crosseyed.Search"> <result name="input">/crosseyed/Search.jsp</result> <result type="redirect-action">Display</result> </action> I.e. Search.jsp -> Search action class -> Display.jsp On the Search.jsp page, one can enter some keywords. The Search action is then executed, after which one is redirected to the Display.jsp which would display the results (data received from the session bean). I've tried setting the value of the Search action property I'm trying to access from Display.java to a constant value, but even then nothing is output in the JSP. I'm the syntax you specified in your reply: <s:property value="%{dataFromSessionBean}" /> The dataFromSessionBean has it's getter and setter methods defined. My spontaneous question is if one has to define somewhere (such as in the struts.xml file) that the action object be placed on some stack. Or do I have to define the name of the Action also, when using the s:property tag? I've tried various other ways, like <s:property value="%{Search.dataFromSessionBean}" /> among others, but none works. Thanks again. Mark Menard wrote: > > On 11/30/06 5:29 PM, "Don Brown" <[EMAIL PROTECTED]> wrote: > >> If you only need request-scoped data, you don't need to bother with >> the ScopeInterceptor or even the ServletRequestAware interface. >> Simply define a getter on your action that returns the object in >> question, then access it via your JSP via JSP EL (JSP 2.0), a JSTL >> expression, or a Struts 2 property tag. > > To expand on Don's answer. (I know he's busy. Thanks Don.) > > Let's say you have the following Action (this is not a complete listing): > > > public class MyAction extends ActionSupport { > > private String dataRetrievedFromSessionBean; > > public String execute () throws Exception { > MySessionBean sb = getSessionBean (); > this.dataRetrievedFromSessionBean = sb.getMyData (); > return SUCCESS; > } > > public String getDataRetrievedFromSessionBean () { > return this.dataRetrievedFromSessionBean; > } > > private MySessionBean getSessionBean () { > // Some code to get your EJB. > } > } > > In your JSP you can display this data with the <s:property> tag: > > <s:property value="%{dataRetrievedFromSessionBean}" /> > > That's it. > > You don't need to mess with Session scope, other interceptors, or any of > that stuff. It's very simple and elegant. Almost too much so. It eluded me > for a while, but now I'm really starting to get it, and it's good. > > Mark > -- > Mark Menard > personal: http://www.vitarara.org/ > business: http://www.vitarara.net/ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Struts-2-and-passing-data-using-interceptors-tf2734105.html#a7654246 Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]