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.
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.