• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Parul Tripathi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"pls" is not a word. Please use real words such as "please" when posting to the forums.

thanks,
bear
Forum sheriff
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Parul Tripathi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i want one web application making request to another web application.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic