Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reloading JSP page when there is any update in the database

 
Keerthi Chandhu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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.


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65226
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like the common caching issue. Please see the JSP FAQ on this issue.
 
ujjwal soni
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • 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
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • 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: 403
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65226
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic