• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic