tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "cyril vidal" <cyr.vi...@wanadoo.fr>
Subject getContext returns null!
Date Fri, 21 Nov 2003 09:49:28 GMT
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.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message