You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by BIJO_THOMAS <BI...@inf.com> on 2000/08/07 09:41:00 UTC
RequestDispatcher across two web contexts
Hello,
This is about forwarding the HttpRequest from a servlet in one web
application to another.
Here is the code snippet I am using.
ServletConfig config = getServletConfig();
ServletContext sc = config.getServletContext();
ServletContext newSC = sc.getContext("/Mainmenu");
if(newSC != null)
{
RequestDispatcher rd = newSC.getNamedDispatcher("/mmenu");
rd.include(req,res);
}
The RequestDispatcher returned by newSC.getNamedDispatcher("/mmenu") is null
and therefore rd.include() raises NullPointerException. Both web
applications are deployed in the same tomcat server (ver 3.1) and '/mmenu'
is a registered alias in the Mainmenu.war's web.xml. Also the URL
http://serverhost:port/Mainmenu/mmenu gives the expected result.
I am able to successfully dispatch request to other non-java files including
jsp files.
It will be greatly appreciated if anybody can throw some light into it.
Regards,
Bijoy
Email: bijo_thomas@inf.com
Re: RequestDispatcher across two web contexts
Posted by "정병완 (byung-wan,jung)" <bw...@selim.co.kr>.
HI,
Maybe, I thik that I will help you.
-----------------------------
public class WebletServlet extentds HttpServlet {
public static final String jsppage = "/jsp/Screen.jsp";
..
public void service( HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
RequestDispatcher sld = this.getServletContext().getRequestDispatcher(jsppage);
sld.forward(req, res);
}
}
----- Original Message -----
From: BIJO_THOMAS <BI...@inf.com>
To: <ge...@jakarta.apache.org>
Sent: Monday, August 07, 2000 4:41 PM
Subject: RequestDispatcher across two web contexts
> Hello,
>
> This is about forwarding the HttpRequest from a servlet in one web
> application to another.
>
> Here is the code snippet I am using.
>
> ServletConfig config = getServletConfig();
> ServletContext sc = config.getServletContext();
> ServletContext newSC = sc.getContext("/Mainmenu");
> if(newSC != null)
> {
> RequestDispatcher rd = newSC.getNamedDispatcher("/mmenu");
> rd.include(req,res);
> }
>
> The RequestDispatcher returned by newSC.getNamedDispatcher("/mmenu") is null
> and therefore rd.include() raises NullPointerException. Both web
> applications are deployed in the same tomcat server (ver 3.1) and '/mmenu'
> is a registered alias in the Mainmenu.war's web.xml. Also the URL
> http://serverhost:port/Mainmenu/mmenu gives the expected result.
>
> I am able to successfully dispatch request to other non-java files including
> jsp files.
>
> It will be greatly appreciated if anybody can throw some light into it.
>
> Regards,
> Bijoy
> Email: bijo_thomas@inf.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org
>