posted 17 years ago
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 ?