This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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.
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?
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.
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?
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
posted
0
You can choose, the most suitable one for you, from the list given by Ulf.