aspose file tools*
The moose likes JSP and the fly likes Persisting objects (in memory) in application scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Persisting objects (in memory) in application scope" Watch "Persisting objects (in memory) in application scope" New topic
Author

Persisting objects (in memory) in application scope

Kevin Fedric
Greenhorn

Joined: Jan 29, 2012
Posts: 4
First let me brief you with app structure. Client is ExtJS UI and any request to data from server involves call to specific JSP page at server. JSP page in-turn invokes method from core java classes in 'data' package to get the requested data. This data returned by method call is in json format, so JSP simply returns the data back to client. I am using MySQL database and the JDBC stuff is handled by core java classes in 'data' package.

Now, the client has to get data from back end by making two subsequent separate calls to back end. These call happen on user interaction. In first call, say Call-1 queries one set of data from mysql (for example - a list of employees) and returns to client. On second, subsequent call (Call-2) the backend has to work with data already retrieved in Call-1. (For example, return Facebook profile URLs of each employee in the list retrieved in call-1).
Now I want a way to keep the list of employees (of call-1) in memory, so that I can directly start processing data from call-2 instead of querying mysql again.

I searched in google to do this, and I came across the concepts of session variables, application variables, context variables, etc. Being a newbie, am not sure which is the correct choice. I need to dig deeper in that, but given the limited time I have to work on this - I just thought of asking here for the right direction. I will appreciate some help on this front from forum members.

I have recently got into server side programming with Java. So it would be great to have some feedback on my application structure. Am I following the usual common/standard way to structure the client/server/db interactions (use of core java classes interacting directly with JSPs) and stuff like that? How and what can I improve in structuring the application.

Thanks.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
135

Kevin,
Search for MVC (model view controller). It shows how to have your Java objects interact with the JSP. The short story is that the JSPs just render the view and don't have any logic. This happens from a servlet before the JSP gets called.

It is common to store data in the HttpSession. Especially if it is user specific or short lived (session scored). Unless it is huge. All of these conditions sound like they match your scenario. The application context is for global cached type data.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60045
    
  65

Please read this article.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Persisting objects (in memory) in application scope
 
Similar Threads
Expanding an application for multiple clients
Properties/Settings - a design question
ibm websphere test 157 for websphere studio application developer 4.0.3 for windows
IBM HttpServer and websphere Appserver
pagination in jsp