Hi,

I just would like to get a reference to the ServletContext of another web application 
as the current one, to get a RequestDispatcher object.

I know that the path should begin with / and that it is interpreted relative to the 
server's document root .

So i'm in a web application context and would like to get the context of 
c:\tomcat\webapps\tutobean application.

I've written the following code:

protected void doGet(HttpServletRequest req, HttpServletResponse rep)

throws ServletException, IOException {

ServletContext currentSC = getServletContext(); //reference to the current 
ServletContext

ServletContext distantSC = currentSC.getContext("/tutobean"); //reference to the 
ServletContext of tutobean webappl, corresponding to http://localhost:8080/tutobean.

distantSC.getRequestDispatcher("/index.html").forward(req,rep); //NullPOinterException 
here because distantSC is null!!!



What's wrong in my code?

Thanks for your response,

Regards,

Cyril.

Reply via email to