aspose file tools*
The moose likes Servlets and the fly likes how do files of one war file will access files of other war file 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 » Java » Servlets
Bookmark "how do files of one war file will access files of other war file" Watch "how do files of one war file will access files of other war file" New topic
Author

how do files of one war file will access files of other war file

Parul Tripathi
Greenhorn

Joined: May 26, 2007
Posts: 13
how do files of one .war file will access files of other .war file both deployed in the same server. pls reply.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

"pls" is not a word. Please use real words such as "please" when posting to the forums.

thanks,
bear
Forum sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Parul Tripathi:
how do files of one .war file will access files of other .war file both deployed in the same server. pls reply.


Do you mean one web application making request to another web application ?


Rahul Bhattacharjee
LinkedIn - Blog
Parul Tripathi
Greenhorn

Joined: May 26, 2007
Posts: 13
yes i want one web application making request to another web application.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Synchronizing file access across contexts is tricky. Or is just read-only access?

Obviously, you'need to know the path to the file, which includes the name of the other web app, and its internal structure. This goes a bit against the encapsulation one is trying to achieve with web apps. Maybe it would be possible for the web apps to only access their own files, and have the others make HTTP requests to it? Or move the common files to a shared directory somewhere else?


Ping & DNS - my free Android networking tools app
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Ah. Now I see that you're actually talking about requests, not files.

You can use the java.net.HttpUrlConnection class to make HTTP requests, or -for more features- the Jakarta Commons HttpClient library. What kind of data were you thinking of sending back to the calling web app?
Rajesh Agarwal
Ranch Hand

Joined: Aug 01, 2005
Posts: 79
There is a method on the ServletContext object that allows for access to another WAR's servlet context - DEPENDING ON THE VENDOR's IMPLEMENTATION. If you call the getContext(java.lang.String uripath) with another WAR's servlet context - it will give you a reference to that web apps servlet context. I beleive that is the default implementation for weblogic, but again, your mileage may vary
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how do files of one war file will access files of other war file