File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Sharing data between web app's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sharing data between web app Watch "Sharing data between web app New topic
Author

Sharing data between web app's

vijay kumarg
Ranch Hand

Joined: Dec 14, 2006
Posts: 105
What is the best way of sharing data between web apps
request or session or application?
D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

database


Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

All option are depends on your needs.

Session: when you want to share your data in your whole application. like user_id.
Request: its just use for forward and recieve the data between webpages but its data just shareable for next and last hit webpages.. not like session.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41472
    
  51
..., or socket connections, or files, or email, or JMS, or HTTP, or web services, or ...

That's too broad a question to answer without knowing the details of what you want to share, how often it changes, etc.


Ping & DNS - my free Android networking tools app
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Saif uddin:
Session: when you want to share your data in your whole application. like user_id.


Nope.

Session: The information is available throughout the session till session is invalidated

Request: The information is available just for that particular request cycle after that that particular request is disposed off
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by vijayk gopu:
What is the best way of sharing data between web apps
request or session or application?


These scopes would not be available out of the context. Or you can use some stateful beans. Indeed, you can send some data using request parameters.

Other options are already mentioned.
leonardo battagli
Ranch Hand

Joined: Aug 28, 2003
Posts: 33
Originally posted by Adeel Ansari:


These scopes would not be available out of the context. Or you can use some stateful beans. Indeed, you can send some data using request parameters.

Other options are already mentioned.


Ok, btw HttpSession API confirm this
"Session information is scoped only to the current web application (ServletContext), so information stored in one context will not be directly visible in another."

but what that 'directly' means?
which are the not-so direct way to access to session info from a different web context?
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
You can try this , but would not recomend this.

Write a singleton repository , which can store key , value pairs and then place those classes in shared/classes , so that this is visible to all the web applcations.


Rahul Bhattacharjee
LinkedIn - Blog
leonardo battagli
Ranch Hand

Joined: Aug 28, 2003
Posts: 33
Originally posted by Rahul Bhattacharjee:
You can try this , but would not recomend this.

Write a singleton repository , which can store key , value pairs and then place those classes in shared/classes , so that this is visible to all the web applcations.


what does that 'singleton repository' means?

It means, create an object with the singleton pattern and store it in shared/classes of the ear, so that both application can access it?
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
simple: do NOT do this. If you need to send data from one web app to another store it in a database used by both or send http requests to servlets back and forth.

Do NOT attempt to write some class, instances of which you hope will be available to both applications.
It's not going to work, and even if you think it does it's not at all scalable and extremely poor design.


42
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
You can choose, the most suitable one for you, from the list given by Ulf.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Adeel Ansari:

Session: The information is available throughout the session till session is invalidated

Request: The information is available just for that particular request cycle after that that particular request is disposed off


agreed with more clear picture..
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by leonardo battagli:


what does that 'singleton repository' means?

It means, create an object with the singleton pattern and store it in shared/classes of the ear, so that both application can access it?


yes..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sharing data between web app's