As Chris suggests, directly accessing methods on another servlet is not 
really a good idea. If you have data that needs to be available to JSP 
pages application-wide, then you could consider storing it as an 
application-scope attribute. However, storing it at the most local scope 
possible is best.

If you really, really need to get access to the servlet, the following 
should work, although I've never actually tried it:

<bean:struts id='yourMapping' mapping='yourMappingName'/>
<bean:define id='yourServlet' name='yourMapping'
     property='mappings.servlet'/>

I concur with Chris's book recommendation, too. It's definitely worthwhile 
reading to get a good understanding of JSP, and servlets as well.

--
Martin Cooper


At 10:11 AM 10/22/01, Chris Morin wrote:
>Antonio,
>
>         I imagine you could:
>
>         request.setAttribute( "servlet", this );
>
>         before forwarding to your jsp page.  You'll need to expose getter
>methods to your jsp page to access the object's properties.
>
>         But I would recommend just putting the servlet's properties into the
>request individually, either with setParameter() or setAttribute().
>
>         A good manual on JSP development can explain in detail methods for
>transferring information between servlets and jsps.  Web Developement with
>JavaServer Pages by Fields and Kolb is fairly comprehensive and thorough.
>
>.c.
>
>-----Original Message-----
>From: Antonio Vianello [mailto:[EMAIL PROTECTED]]
>Sent: Monday, October 22, 2001 9:25 AM
>To: Struts-User Mailing List
>Subject: Newbie question
>
>
>Hi to you all.
>
>Sorry if my question could seem quite obvious, but how can I get a reference
>to the ActionServlet instance from within a JSP page? I need this to have
>access to some custom fields I've defined in the servlet class.
>
>Thanks in advance
>
>Antonio


Reply via email to