• 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

Reloading JSP page when there is any update in the database

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can anyone please suggest me how to reload a JSP page when user updates any value in the database from the screen?

Actually when user changes any value in the JSP it is being updated in the database but it is not giving the updated value in the JSP until user manually Refresh the page.

Thank you.


 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like the common caching issue. Please see the JSP FAQ on this issue.
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Try doing this.

<% response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
%>


Hope it works
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ujjwal soni wrote:
<% response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
%>


1) Scriptlets always indicate a bad practice.
2) Code duplication is always a bad practice.
3) You're overriding the correct Cache-Control header with an incorrect one.
 
ujjwal soni
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your suggestion...

Prevent caching of JSP output

Put following scriptlet at the beginning of the JSP to prevent output caching


 
Keerthi Chandhu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ujjwal soni ,

Thank you so much for the reply.

I tried making cache control

but it is not updating with the updated value utill I click refresh manually.

Actually to decrease number of queries to database, I am passing database values as parameters to another jsp and while displaying I am getting those parameters using


when I update this value, it is getting updated in database but it is not displaying the updated value until I click refresh manually.
Would appreciate your help.

Thank you,
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ujjwal soni wrote:Put following scriptlet at the beginning of the JSP to prevent output caching


As previously pointed out, scriptlets are a poor practice. This should either be done in the page controller, or better yet, in a filter.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ujjwal soni wrote:Hi,

Thanks for your suggestion...


You're good at Googling. Why don't you explain the topicstarter how to do it so that s/he can learn from it? Why don't you mention the source of this information?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic