aspose file tools*
The moose likes Websphere and the fly likes Is it possible to include an other web app's file in a jsp page in a web app? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Is it possible to include an other web app Watch "Is it possible to include an other web app New topic
Author

Is it possible to include an other web app's file in a jsp page in a web app?

Adam Tao
Greenhorn

Joined: May 15, 2003
Posts: 20
Hi,
I use WSAD5 and WAS5 as development tool and application server. I have 3 web apps in an enterprise app (1 ear file). I want to share some static files among these 3 web apps. I put some static files in one web app uses "/" as context root. I can share these static files in other 2 web apps if I only use html links or javascript src. If I need to use jsp include directive or action. The relative URL that locates the resource to be included, or an expression that evaluates to a String equivalent to the relative URL. The relative URL looks like a pathname--it cannot contain a protocol name, port number, or domain name. The URL can be absolute or relative to the current JSP page. If it is absolute (beginning with a /), the pathname is resolved by your web or application server.
Is it possible to include an other web app's file in a jsp page in a web app using jsp include directive or action?
Thanks,
Adam


Adam <br /> <br />Sun Certified Enterprise Architect for J2EE<br />IBM Certified for e-business - Solution Designer<br />IBM Certified Advanced System Administrator - WebSphere Application Server V5.0<br />IBM Certified Solution Developer - XML and Related Technologies<br />IBM Enterprise Application Development with IBM WebSphere Studio, V5.0
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

It is possible, but it is oftemn seen as a security risk and is fraught with danger anyway. I know it's theoretically possible but it's quite server specific and I've never seen anyone get it right.
It works like this:
To include a JSP in a web app, you need access to a ReuqestDispatcher. RequestDispatchers are specific to a web app context. You can find another web application context if you know its name. Given the context of the other web app, you can get a RequestDispatcher from that web app. You can now get that RequestDispatcher to include the JSP in the current web app.
Sounds like a lot of work, but it looks like this:
(the current context is "/app1", the second context is "/app2", app2 contains the jsp "/app2/app2.jsp" that you want to include in app1.)

If you want to concatenate JSPs like this you're likely to fail. The last time I saw someone try to do it in WAS (4.0.3 from memory) the included jsp turned up at the end regardless of what we tried. My guess was that the remote RequestDispatcher was being managed by a separate thread and this was causing the problem, but we never tried to solve it.
Hope it helps, give us feedback on how you go!
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible to include an other web app's file in a jsp page in a web app?