tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Wingfield <jon.wingfi...@mkodo.com>
Subject Re: getContext returns null!
Date Fri, 21 Nov 2003 10:19:27 GMT
I think you may need to set your Context to be crossContext.

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/context.html

HTH,

Jon


cyril vidal wrote:
> 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.
> 




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


Mime
View raw message