• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

how to refresh the jsp page when onload?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my page display the contents in a database,
but each time it is loaded, it doesn't display the updated values in the database, only a 'refresh' makes it display the newly inserted records, what shall i do?
 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you should re-load that page...
Example I have A.jsp which will go the server to load some datas from database...
A.jsp
========
...
<form method="POST" action="A.jsp">
<input type="sumbit" value="Get Data" name="btnSubmit">
</form>
...
It's code to load new data from database and refresh your current page so your page will show the new datas
Correct me if i am wrong...
daniel
 
amanda wu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my page actually reads data out from a database, display it, let user delete some data ,and then display the message in another page.
like a.jsp is my page for it,
then in the action field, i put message.jsp already, so what i want, is after click the submit button, both the message.jsp and a.jsp is called again..
 
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi amanda,
you could let a.jsp call itself.
In your code you do your db-operations first,
if( request.getParameter("btnSubmit") != null )
{
...db-oprarations
%>
<%=thenPrintYourMessage%>
<%
}
and then display your <form>
hth
cb
 
amanda wu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks to you all. but can't the page load updated data from database onload without click button? like i just click a link and get a page displayed, and want the newly displayed page updated ...
I am so suprised all my page get form with data from database is not updated when the link just opened...
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like the browser is just displaying a cached copy of your page? If that is the case you can set some headers to prevent it from being cached:

I hope this helps...
Mark
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want your application to do that.. i think there are 2 options you can do...
1. You can add your jsp page with
<meta http-equiv="refresh" content="1000">
It will refresh the page every 1 minute..
2. You can use servlet class to get data from database... and within your jsp page you can use href link...
Example :
<a href="GetDataServlet">Get data</a>
correct me if i am wrong...
daniel
[ April 02, 2003: Message edited by: Fisher Daniel ]
 
What are you doing in my house? Get 'em tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic