Solved

Refresh the page and using session.

Posted on 2004-04-04
16
3,508 Views
Last Modified: 2012-08-14
1. What is the coding to refresh or reload the jsp page?

2. What is the coding for session to maintain only 10 minutes on that jsp page.
0
Comment
Question by:YvonneYap
  • 5
  • 4
  • 4
  • +1
16 Comments
 
LVL 13

Expert Comment

by:copyPasteGhost
Comment Utility
>>1. What is the coding to refresh or reload the jsp page?

The following tag loads the page foo.html after 5 seconds.
<META HTTP-EQUIV="Refresh" CONTENT="5;URL=http://www.somehost.org/foo.html">
To cause a reload on the same resource, don't specify the alternative URL.

>>2. What is the coding for session to maintain only 10 minutes on that jsp page.

HttpSession hsObj = request.getSession(); hsObj.setMaxInactiveInterval(600);

the setMaxInactiveInterval accepts the amount of seconds. therefore 10 min = 60 X 10 = 600 seconds

cheers,
Ghost
0
 

Author Comment

by:YvonneYap
Comment Utility
I have try the refresh coding but it keep on prompting the alert message in Internet Explorer saying that the page cannot be refresh without resending the information. Click retry to send the information or cancel to return the page u are viewing... How to prevent the alert message from coming out?
0
 
LVL 13

Expert Comment

by:copyPasteGhost
Comment Utility
jsp is a server side language...that means the the code is generated on the server and then sent to the client as html..

I don't think that you can reload the page without resending the information to the server?

why exactly do you want to refresh the page? maybe there is another way to do what you want to do..
Ghost
0
 

Author Comment

by:YvonneYap
Comment Utility
hmm... Actually i am retrieving the data from the database and display the data to the JSP page. Then I can edit the JSP page to update some of the data... Example, (retrieve from database) address: Jurong. When i change the address: Yishun and click on the update button, it will update the data to my database then come to a JSP page where all my updated data displayed. Now the problem come... the JSP page display address: Jurong first instead of Yishun which i have already updated. But when i click on refresh, it give me the address: Yishun.  I am not suppose to click on the refresh in order to get my data display correct.... that is why i want coding for the reload on that particular jsp page. Do you have any suggestion like using the javascript reload method or other suggestion?  If have, provide the coding please...
0
 
LVL 13

Expert Comment

by:copyPasteGhost
Comment Utility
ummm I have an idea... you can do this...

if this is your .....form.jsp
<%
sqlQuery = ("Select FirstName,LastName FROM myTable");
rs = statement.executeQuery(sqlQuery);
areMore = rs.next();
String fName = "";
String lName = "";
if (areMore) {
  do {
    fName = rs.getString("FirstName");
    lName = rs.getString("LastName");
  } while ( rs.next() );  
}  
%>

<html>
 <body>
   <form method="post" action="update.jsp">
     <table>
       <tr>
         <td>*First Name</td>
         <td><input type="text" name="fName" size="30" value="<%= fName%>" /></td>
       </tr>
       <tr>
         <td>*Last Name</td>
         <td><input type="text" name="lName" size="30" value="<%= lName%>" /></td>
       </tr>
     </table>
   </form>
 </body>  
</html>

and then this is your: update.jsp

<%
String fName = request.getParameter("fName");
String lName = request.getParameter("lName");

sqlQuery = ("Update myTable set FirstName = '" + fName+ "',LastName = '" + lName+"'");
statement.executeUpdate(sqlQuery);

%>
<jsp:forward page="form.jsp" />

YOU MUST REMEMBER TO ADD A WHERE Clause on the UPDATE statement or else every field in your database will be changed..

try that and let me know,
Ghost
0
 
LVL 13

Expert Comment

by:copyPasteGhost
Comment Utility
oh yeah the reload function for javascript will still make you have to answer that "resubmit" question box...

I think the way I suggested will fix your problems,
Ghost
0
 
LVL 6

Accepted Solution

by:
jarasa earned 50 total points
Comment Utility
Try putting this on your JSP page
<%
      response.setHeader("Cache-Control", "no-cache");
      response.setHeader("Pragma", "no-cache");
      response.setDateHeader("max-age", 0);
      response.setDateHeader("Expires", 0);
%>
I thing your problem is with the Cache not with the data.

Javier

About the session exipiration, you can set it on web.xml in /conf dir if you're using TOMCAT

  <!-- ==================== Default Session Configuration ================= -->

  <!-- You can set the default session timeout (in minutes) for all newly   -->
  <!-- created sessions by modifying the value below.                       -->

  <session-config>
    <session-timeout>10</session-timeout>
  </session-config>

Javier
0
 
LVL 6

Expert Comment

by:jarasa
Comment Utility
Forget about the session thing I didn't notice that you only wanted for that JSP.
Javier
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 14

Expert Comment

by:kennethxu
Comment Utility
>> Forget about the session thing I didn't notice that you only wanted for that JSP.
no, once you set seesion on one jsp, it sets for all other pages in the same session. so it is almost the same between setting in jsp and web.xml.
0
 
LVL 6

Expert Comment

by:jarasa
Comment Utility
>no, once you set seesion on one jsp, it sets for all other pages in the same session. so it is almost the same >between setting in jsp and web.xml.

I know kenneth but if you have it on web.xml it will be the same for all applications on the server, right?

If you set the timeout on each application start page it would be different as long as you open each with a differen browser, Tha's why I said to forget it.

:c)

Javier
0
 
LVL 14

Expert Comment

by:kennethxu
Comment Utility
>> but if you have it on web.xml it will be the same for all applications on the server, right?
no, it's per webapp configuration, you only change the web.xml of the application you want to change.
0
 
LVL 6

Expert Comment

by:jarasa
Comment Utility
>no, it's per webapp configuration, you only change the web.xml of the application you want to change.
Kenneth I'm talking about the /conf/web.xml not /WEB-INF/web.xml

0
 
LVL 14

Expert Comment

by:kennethxu
Comment Utility
why it's a B grade again?
and copyPasteGhost's initial answer was also correct.
0
 
LVL 14

Expert Comment

by:kennethxu
Comment Utility
if asker don't give reason for B grade in next few days. I'll report to EE admin.
http://www.experts-exchange.com/Web/Web_Languages/JSP/help.jsp#hi73
0
 
LVL 13

Expert Comment

by:copyPasteGhost
Comment Utility
yeah I was thinking the same thing..
thanks ken :)
cheers
Ghost
0
 

Author Comment

by:YvonneYap
Comment Utility
hey please la... people want to give is people business right. So childish...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Marketing can be an uncomfortable undertaking, especially if your material is technology based. Luckily, we’ve compiled some simple and (relatively) painless tips to put an end to your trepidation and start your path to success.
Veeam Backup & Replication has added a new integration – Veeam Backup for Microsoft Office 365.  In this blog, we will discuss how you can benefit from Office 365 email backup with the Veeam’s new product and try to shed some light on the needs and …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now