• 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

To put in the session or in the request ?

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic