Hi,
Does anyone knows, where to subscibe the forum of ejbs.
 
Thanx in advance.
 
Hamid Hassan
Visualsoft Pvt. Ltd.
 
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of Duffey, Kevin
Sent: Tuesday, August 07, 2001 4:29 AM
To: [EMAIL PROTECTED]
Subject: Re: Working with multiple WAR files in a single container?

Yes..infact, using request to get the RequestDispatcher() only works to forward to paths relative to that of request URI path itself. It is not relative to the ServletContext the request handler is running in (request handler being the ControllerServlet).
 
I solved it by adding a context="" parameter for each forwarding resource in my framework. Now, if a resource to be forwarded to exists in another web-app context, simply add the context="/web-app-context" to the resource forwarding declaration will allow it to use that context instead. You'd have to use my Theseus framework (www.brainopolis.com/theseus) to see it in use.
 
The trick is to grab the ServletContext of the web-app you want to forward to, then forward using a relative path to the root of THAT ServletContext. I was grabbing the right ServletContext, but was forwarding relative to the root web-app context "/", and not of the one I wanted to go into "/inside" or "/admin".
 
Seems to work fine now. Funny thing is, I don't think Struts handles this correctly. Not sure, but looking at the source on how Struts forwards to a resource, its done the same way I was doing it before. I could be wrong..perhaps somewhere in that huge list of code there is a bit that grabs the ServletContext of the desired web-app, but I couldn't find it. What this means is that Struts will not allow you to properly forward from inside one deployed web-app into another web-app running in the same JVM. I will suggest this fix to the Struts team so that possibly this will work for them as well.
 
-----Original Message-----
From: Shawn Zhu [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 06, 2001 4:27 PM
To: [EMAIL PROTECTED]
Subject: Re: Working with multiple WAR files in a single container?

have you tried simply:
  request.getRequestDispatcher("/index.jsp").forward(reuqest,response);
 
I am assuming you are not doing outside_server->forwardto->inside_server.
-----Original Message-----
From: Duffey, Kevin [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 06, 2001 12:19 PM
To: [EMAIL PROTECTED]
Subject: Working with multiple WAR files in a single container?

Hi all,
 
Deploying 3 web-apps in one container. Outside, Inside and Admin. Outside is mostly static, with a login section. The login section takes the user to the Inside app. This all works. Problem occurs when I try to get a user to forward to a JSP page in the outside application. Using my MVC framework, I get a RequestDispatcher for the forwarding URL which is a "relative" URL to the web-app its in. I figured out by using SerlvetContext.getContext(url) to get the ServletContext of any web-app running, but using that ServletContext's RequestDispatcher doesn't seem to allow me to forward to a JSP page in that context. For example:
 
 
 
/ = outside web app
/inside = inside web-app
/admin = admin web-app
 
 
Lets say we are in the ControllerServlet of the /inside web-app:
 
request.getContextPath()   = /inside
 
I want to forward TO the outside web-app index.jsp page. I have /index.jsp, /inside/index.jsp, and /admin/index.jsp. I do the following bit of code to forward from within the /inside web-app context to the / outside index.jsp page:
 
ServletContext sc = getServletContext().getContext("/index.jsp");
 
This correctly gives me the / context, as I tested this by having the /index.jsp page set an attribute, and in the ControllerServlet I can successfully get that attribute.
 
Now, this call always results in a 404 error:
 
sc.getRequestDispatcher("/index.jsp").forward(reuqest,response);
 
 
Ideally, since the "/index.jsp" indicates its in the / (root or outside) context, it should forward to the index.jsp page in this context. On the other hand, because I already have a ServletContext of the outside app, perhaps just "index.jsp" is used. I tried this and still get 404 error.
 
So, any ideas why, or how, to forward from a servlet running in one web-app, to a servlet/jsp page in another web-app? I know according to the spec you can't pass data among web-apps (other than through JNDI), but I sure would like to separate our outside, inside and admin sites into their own WAR files, but still be able to move from one web-app to another. If I kept it all in a single web-app, then using the paths of /admin, /inside or / would work fine. So I am unclear as to why getting the ServletContext of any given web-app OR just trying to forward to a path using the relative "root" path, would work. The API is not exactly clear on how this works.
 
Thanks.

Reply via email to