I agree. It is as simple as setting the path of the forward to a path
that will invoke the servlet...but servlets may have names or mappings
that may also be used in the path.

For example, I'm using Velocity (instead of JSPs) to view the result of
the action. Here's a snippet of the web.xml that defines the servlet:

    <servlet>
      <servlet-name>velocity</servlet-name>
      <servlet-class>com.acme.MyVelocityServlet</servlet-class>

      <!-- more stuff here -->

    </servlet>

  <servlet-mapping>
    <servlet-name>velocity</servlet-name>
    <url-pattern>*.vm</url-pattern>
  </servlet-mapping>


Because I have a servlet mapping, all requests with paths ending in .vm
issued on this web application invoke the velocity servlet (just like
all the ones ending in .do are mapped to the Struts ActionServlet in my
application.

This allows a forward such as:

   <forward name="menu" path="/mainMenu.vm" />

to invoke another servlet using mapping.

If a servlet is given a name in the web.xml, it can also be invoked via:

   <forward name="menu" path="/servlet/velocity" />

or the full class name can be used:

   <forward name="menu" path="/servlet/com.acme.MyVelocityServlet" />


-----Original Message-----
From: Richard Yee [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, May 09, 2002 10:48 PM
To: Struts Users Mailing List
Subject: Re: Q: forwarding to a servlet

Malcom,
If I understand your question correctly, all you would have to do is set

the path attribute of the forward tag of your Action mapping to the
desired 
servlet path.
ex.           <forward name="nextPage"
path="/WEB-INF/classes/yourServlet"/>

Regards,

Richard


At 08:59 PM 5/9/2002 -0700, you wrote:
>I'm not clear on how to forward from the action routine to a servlet
(in
>instead of a jsp).  Is there an example of forwarding to a servlet I
could
>examine?
>
>Pointers welcome, thanks.
>
>
>
>--
>To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to