Hello,
I have one question regarding the implementation of session in the
jsp's. For using the objects in the session, there are two approaches that can be followed. First approach is that in jsp the code looks like this :
<jsp:usebean id="Constants.FINAL_VARIABLE" scope="session" type="ObjectClass">
Here every jsp has to know about the object to be retrieved from the session. Second approach is where there is a static class, which is called by the jsp, and the static class returns the object from the session based on the parameter passed. Like in the jsp the code will look like this:
SessionHandler.getObjectFromSession("Constants.FINAL_VARIABLE",session);
The point here is that from the jsp a session object is passed a parameter to the method of the static class, which brings the most important thing WILL THIS IMPACT PERFORMANCE ??
To explain this thing better, lets say there is an object1 which is stored in session, the object 1 has a property which is object2, and this object 2 contains a
string property. In the first approach to get the property of object2, the code has to be written for retrieving object1 and then object 2 and then the string property, which is fine, in the second implementation only a key is passed to the static class, which does the retrieving of the object1 from the session and then retrieving of object2 from object 1, which is again fine. Now in case the implementation changes in a way that object2 is not going to be a property of object1, instead its going to be a seperate object in the session, then in that case, there will not be any changes to be made in the jsp in the second approach, since the actual implementation is with the static class which will be changed, but in the first approach the jsp needs to be changed.
I am confused as to what approach to follow, basically the only thing that I am doubtful abt is the passing of the session object from the jsp in the second approach. 'PERFORMANCE' is the key
word here.
I will really appreciate if the
J2EE gurus help me out over here.
Thanks