This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes how to refresh the jsp page when onload? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to refresh the jsp page when onload?" Watch "how to refresh the jsp page when onload?" New topic
Author

how to refresh the jsp page when onload?

amanda wu
Greenhorn

Joined: Mar 16, 2003
Posts: 25
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?
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
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

Joined: Mar 16, 2003
Posts: 25
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..
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
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

Joined: Mar 16, 2003
Posts: 25
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...
Mark Bensing
Ranch Hand

Joined: Mar 09, 2003
Posts: 40
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

Joined: Sep 14, 2001
Posts: 582
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to refresh the jsp page when onload?
 
Similar Threads
Real time data using JSP
problem with session and refresh button
how to display time in jsp page
HOw to disable the Refresh property in the Current window
Inserting a record in Database after refreshing a page