You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jane Eisenstein <Ja...@MEDecision.com> on 2005/07/19 21:20:19 UTC

how forward to servlets?

I am integrating Struts into an application containing servlets. I would
like to invoke these from Struts components, but am having a problem
getting this configured. My application's web.xml contains:
 
 <servlet>
  <servlet-name>LogonServlet</servlet-name>
  <display-name>LogonServlet</display-name>
  <servlet-class>com.med.servlet.cp.LogonServlet</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>LogonServlet</servlet-name>
  <url-pattern>/servlet/com.med.servlet.cp.LogonServlet</url-pattern>
 </servlet-mapping>
 
Its struts-config.xml contains 
<global-forwards>
<forward name="logonServlet"
path="/servlet/com.med.servlet.cp.LogonServlet"/>
</global-forwards>

When I try to load this servlet via this code:
 
<frame name="main" 
  src="logonServlet.do&targetAction=displayLogonPage" 
  scrolling="auto" 
  marginwidth="0" 
  noresize
 marginheight="0">
 
the request reaches the ActionServlet but results in this error being
logged:
RequestProces E org.apache.struts.action.RequestProcessor Invalid path
/logonServlet was requested

What am I doing wrong?

--------------------------------------------------------------
Jane Eisenstein
MEDecision, Inc.
phone: 610-540-0202 ext. 1285
email:  Jane.Eisenstein@MEDecision.com

 

Re: how forward to servlets?

Posted by Michael Jouravlev <jm...@gmail.com>.
On 7/19/05, Aleksandar Matijaca <am...@gmail.com> wrote:
> How about:
> 
> response.sendRedirect("/yourcontext/YourServlet");

He wants to forward, not to redirect. I guess, something like this should work:

RequestDispatcher disp = 
  getServletContext().getNamedDispatcher("LogonServlet");
disp.forward(request, response);

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: how forward to servlets?

Posted by Aleksandar Matijaca <am...@gmail.com>.
How about:

response.sendRedirect("/yourcontext/YourServlet");

inside of your code??

Regards, Alex.


On 7/19/05, Dave Newton <ne...@pingsite.com> wrote:
> 
> Jane Eisenstein wrote:
> 
> > <servlet>
> > <servlet-name>LogonServlet</servlet-name>
> > <display-name>LogonServlet</display-name>
> > <servlet-class>com.med.servlet.cp.LogonServlet</servlet-class>
> > </servlet>
> > <servlet-mapping>
> > <servlet-name>LogonServlet</servlet-name>
> > <url-pattern>/servlet/com.med.servlet.cp.LogonServlet</url-pattern>
> > </servlet-mapping>
> >
> >Its struts-config.xml contains
> ><global-forwards>
> ><forward name="logonServlet"
> >path="/servlet/com.med.servlet.cp.LogonServlet"/>
> ></global-forwards>
> >
> >When I try to load this servlet via this code:
> >
> ><frame name="main"
> > src="logonServlet.do&targetAction=displayLogonPage"
> > scrolling="auto"
> > marginwidth="0"
> > noresize
> > marginheight="0">
> >
> >the request reaches the ActionServlet but results in this error being
> >logged:
> >RequestProces E org.apache.struts.action.RequestProcessor Invalid path
> >/logonServlet was requested
> >
> >What am I doing wrong?
> >
> >
> Mixing Struts and servlets ;)
> 
> Creating a forward doesn't create an action--what is logonServlet.do? If
> it isn't an action, then why would it have a .do extension? When the
> request processor sees a .do (if you're set up to do extension-based
> struts mappings) it'll try to fire an Action.
> 
> Also, you can't use a forward definition in a non-struts anything,
> because only struts knows about forwards.
> 
> If you are just using a servlet as the contents of a frame then you
> don't need to interact with struts at all.
> 
> Dave
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

Re: how forward to servlets?

Posted by Dave Newton <ne...@pingsite.com>.
Jane Eisenstein wrote:

> <servlet>
>  <servlet-name>LogonServlet</servlet-name>
>  <display-name>LogonServlet</display-name>
>  <servlet-class>com.med.servlet.cp.LogonServlet</servlet-class>
> </servlet>
> <servlet-mapping>
>  <servlet-name>LogonServlet</servlet-name>
>  <url-pattern>/servlet/com.med.servlet.cp.LogonServlet</url-pattern>
> </servlet-mapping>
> 
>Its struts-config.xml contains 
><global-forwards>
><forward name="logonServlet"
>path="/servlet/com.med.servlet.cp.LogonServlet"/>
></global-forwards>
>
>When I try to load this servlet via this code:
> 
><frame name="main" 
>  src="logonServlet.do&targetAction=displayLogonPage" 
>  scrolling="auto" 
>  marginwidth="0" 
>  noresize
> marginheight="0">
> 
>the request reaches the ActionServlet but results in this error being
>logged:
>RequestProces E org.apache.struts.action.RequestProcessor Invalid path
>/logonServlet was requested
>
>What am I doing wrong?
>  
>
Mixing Struts and servlets ;)

Creating a forward doesn't create an action--what is logonServlet.do? If 
it isn't an action, then why would it have a .do extension? When the 
request processor sees a .do (if you're set up to do extension-based 
struts mappings) it'll try to fire an Action.

Also, you can't use a forward definition in a non-struts anything, 
because only struts knows about forwards.

If you are just using a servlet as the contents of a frame then you 
don't need to interact with struts at all.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org