• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem in displaying value from session object

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I working on attachment functionality on JSP page
Here are the steps I follow

1) On the jsp page I selects the file clicks the "Attach" link.
2) The request goes to a servlet which uploads the file to a directory.
3) The servlet shows the messgae "Your file has been uploaded", and a close button below that.
In the servlet I've set the filename in the session object.


4) When I click the "CLOSE" button, the servlet takes me back to the JSP page.
On the "CLOSE" button, I'm using "history.go(-1)", which will take me to the previous page

5) On the JSP page I'm displaying the name of the file, by retrieving from the HttpSession object.

However the file name dosen't get displayed.

When I click the browser's refresh button, the file name gets displayed

Please let me know why the JSP is not able to retrive the value from the session object.

Is it because I haven't submitted a new request.
 
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
It sounds like you're seeing a cached version of the previous page when you click the back button.

Search this forum (and Google) with keywords 'pragma' and 'cache' for tips on preventing your browser from caching pages (browsers are not all compatible in this regard so you may need to suggest it in more than one way to achieve consistent results).

A better approach would be to use the post-redirect-get pattern to eliminate the need to duplicate the back button with Javascript.
After your upload, use response.sendRedirect to redirect the browser to your page. This will force a new request on the client side.
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic