You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Sampige, Srinivas" <sr...@boeing.com> on 2002/04/16 22:26:28 UTC

forwarding request to another resource

Hi
 I have a common base class called EtrackAction that checks for a valid
session. All action classes subclass this base class. What I want to do is -
if a valid session does not exist (which may occur due to sesison timeout) I
want to forward the request to another site which is actually a web site
that authenticates users. The idea is to authenticate the user and help him
continue his session from wherever he is in the web applicaton(he might have
taken a break during a lengthy input process in a large screen). So in
EtrackAction class I forward to "cuisauthentication" which maps to
"relogon.jsp".But the "relogon.jsp" gives an error. Here are the code
snippets and and followed by the stack trace -

--------------------------------
        EtracSessionController controller =
(EtracSessionController)session.getAttribute("etracController");
        System.out.println("EtrackAction: got the controller "+controller);
        //check if a valid user session exists by checking for the existence
        //of the controller
        if (controller==null)
          {
            //if the controller doesn not exist then a valid session
            //does not exist. So, store the incoming request, authenticate
            //the user and preceed futher if the authentication succeeds.
            System.out.println("SESSION HAS TIMED OUT !!!");
            return mapping.findForward("cuisauthentication");
          }
        //a valid session exists so proceed 	 	
        System.out.println("VALID SESSION EXISTS SO PROCEEDING ");
        return performAction(mapping,form,request,response);
--------------------------------

My forwarding section of the :- 
-------------------------------
  <global-forwards>

    <!-- Example logon forward
     <forward   name="logon"                path="/logon.jsp"/>
     -->
     <forward   name="success"              path="/menu.jsp"/>
     <forward   name="logon"                path="/logon.jsp"/>
     <forward   name="cuisauthentication"   path="/relogon.jsp"/>
  </global-forwards>
-------------------------------

The code for my relogon.jsp is
--------------------------------
<%@ page import="javax.servlet.*,javax.servlet.http.*" %>
</HTML>
 <%
    System.out.println("In the relogon.jsp.... trying to forward to authtest
site......");
    ServletContext context = getServletContext();
    RequestDispatcher dispatcher =
context.getRequestDispatcher("http://authtest.internal.ca.com/");
    dispatcher.forward(request,response);
 %>
</HTML>
-------------------------------

Stack Trace is -
-------------------------
A Servlet Exception Has Occurred
java.lang.IllegalArgumentException: Path http://authtest.ca.boeing.com/ does
not start with a "/" character
	at
org.apache.catalina.core.ApplicationContext.getRequestDispatcher(Application
Context.java:570)
	at
org.apache.catalina.core.ApplicationContextFacade.getRequestDispatcher(Appli
cationContextFacade.java:174)
	at org.apache.jsp.relogon$jsp._jspService(relogon$jsp.java:63)
	at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:1264)
	at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:201)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:1264)
	at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.
java:672)
	at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatch
er.java:430)
	at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher
.java:354)
	at
org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.ja
va:1758)
	at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1595)
	at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:1145)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:1264)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:243)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:215)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
	at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
46)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2366)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
	at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:163)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
1005)
	at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1098
)
	at java.lang.Thread.run(Thread.java:484)
------------------------

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: forwarding request to another resource

Posted by Victor Hadianto <vi...@nuix.com.au>.
>    RequestDispatcher dispatcher =
> context.getRequestDispatcher("http://authtest.internal.ca.com/");
>    dispatcher.forward(request,response);


getRequestDispatcher(String path) requires you to supply the path that is 
relative to the context root.

Try to do getRequestDispatcher("/") and see how it goes. Actually if you read 
the stack trace it will tell you exactly what went wrong:

java.lang.IllegalArgumentException: Path http://authtest.ca.boeing.com/ does
not start with a "/" character

Cheers,

-- 
Victor


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>