How can a RequestDispatcher call a servlet in another web application?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
To illustrate this requirement with an example: if a servlet uses the RequestDispatcher to call a servlet in another web application, any sessions created for and visible to the callee servlet must be different from those visible to the calling servlet.
----------------------------------<br />SCJP SCWCD<br />dive into EJB, drinking hot Java
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
this.getServletContext().getContext(uripath)
Anthony W.<br />MCP, SCJP 1.4, SCJD, SCWCD 1.3, SCWCD 1.4, SCBCD
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
But when I tried the following fragment code in the Tomcat 4.1. It return a NullpointerException. Is it a bug of Tomcat 4.1?
try{
ServletContext rootContext = getServletContext().getContext("http://localhost:8080/");
System.out.println( ( rootContext.getAttribute("root") ).toString() );
}catch(Exception e){
System.out.println(e);
}
----------------------------------<br />SCJP SCWCD<br />dive into EJB, drinking hot Java
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Nick
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
In the servlet API, I found the following statement about the getContext():
In a security conscious environment, the servlet container may return null for a given URL.
So, should make any change in the Tomcat to make it work?
----------------------------------<br />SCJP SCWCD<br />dive into EJB, drinking hot Java
| Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |






