• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Persisting objects (in memory) in application scope

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this article.
 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic