• 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

storing a whole page in a session

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello guys

can any one tell me how can i store a whole page in a servlet session?

thanks
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To bind a Java object to session, use
request.getSession().setAttribute(String, Object);
The first argument is the name you give to the object.

To retrieve it use:
reqeust.getSession().getAttribute(String);
You'll need to cast the object back down to it's original type.

So, if you want to cache the entire page to session, write all the text to a String or StringBuffer and bind it to the session.

Why do you want to do this?
 
ali al
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i need to do some thing like this:

i have a page which has two questions and every question has three choices, the user should choose one choice of every quetion, if the user press a button to submit this page with out answering the quetion an error will come up probting the user to go back, so when he goes back he should see one of he is choices unchanged with out using the back button.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The normal way of dealing with this is to retrieve the values from the form,
validate them and redraw the form if any are invalid.
There is no need to store the entire page.
Besides, you'll want to add a message to the page telling the user what values are invalid.
 
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic