| Author |
getRequestDispatcher forwarding across applications
|
David Miranda
Ranch Hand
Joined: Mar 14, 2005
Posts: 34
|
|
Hello, Is it possible to use the RequestDispatcher.forward() method to forward to a servlet in a different context path? For example: I have the following jsp: http://localhost:8080/app1/index.jsp ...that tries to forward to: http://localhost:8080/app2/myServlet Here is the code that I am using in index.jsp: RequestDispatcher rd = request.getSession().getServletContext().getRequestDispatcher("/app2/myServlet"); rd.forward(request,response); It returns null. I could use: response.sendRedirect("/app2/myServlet"); But that sends the response back to the user before requesting the servlet, and would rather not use it if possible. :-/ Thanks! David
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Look at: public ServletContext getContext(java.lang.String uripath) http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html Depending on the container, you may need to do some configuring (lower security) to allow this. In Tomcat, you would set the crossContext property to true in your <Context../> entry.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
David Miranda
Ranch Hand
Joined: Mar 14, 2005
Posts: 34
|
|
I'll try that! Thanks Ben!
|
 |
David Miranda
Ranch Hand
Joined: Mar 14, 2005
Posts: 34
|
|
Hrmmm Any idea how to get another app context using ServletContext.getContext(String uripath) in Weblogic 8.1? Thanks! David
|
 |
 |
|
|
subject: getRequestDispatcher forwarding across applications
|
|
|