Forums Register Login

To put in the session or in the request ?

+Pie Number of slices to send: Send
Hi.
I have a a question that I really want to know how the right answer.
Consider the following scenario :
The user clicks on the following link :
/details.do?isbn=1234567
The action goes to the database (throught Hibernate) and gets the required item and put it in the session scope and forwards the request to details.jsp page.
details.jsp has 'Add to cart' button, when the user clicks the previous button add the required item to the shopping cart and forwards the request to details.jsp to show a successful message.
So, why to put the item object in the session scope instead of request scope ?
Because when details.jsp redisplayed, an exception will be thrown because there is no an item instance in the request scope.
I can use the request scope but this will cost a SQL command (which already excuted) to retrieve the item again.
What do you think ?
+Pie Number of slices to send: Send
I think you already got the right answer. Put things in session scope if they are needed over more than one request. Did you want to hear something else?
+Pie Number of slices to send: Send
Well Sir, please check this :
https://coderanch.com/t/119366/HTML-JavaScript/Reimplementing-parts-app-DWR
Using the session scope was good until I decided integerate Ajax techniques.
[ January 24, 2007: Message edited by: John Todd ]
+Pie Number of slices to send: Send
Sorry, I don't understand what that question has to do with this one. It doesn't make any difference whether the requests to your web application come from link clicking or from Javascript code.
I hired a bunch of ninjas. The fridge is empty, but I can't find them to tell them the mission.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 703 times.
Similar Threads
Performance question
How to know login & logout status of user
Click on the button
SLSB & SessionSynchronization interface
Calling an action using DWR
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:38:39.