Solved

Refresh the page and using session.

Posted on 2004-04-04
16
3,513 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
ID: 10751827
>>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
ID: 10752246
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
ID: 10752248
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:YvonneYap
ID: 10752592
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
ID: 10752642
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
ID: 10752644
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
ID: 10756143
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
ID: 10756157
Forget about the session thing I didn't notice that you only wanted for that JSP.
Javier
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10758758
>> 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
ID: 10763818
>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
ID: 10766151
>> 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
ID: 10766182
>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
ID: 10766185
why it's a B grade again?
and copyPasteGhost's initial answer was also correct.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10766200
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
ID: 10818465
yeah I was thinking the same thing..
thanks ken :)
cheers
Ghost
0
 

Author Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JSP Popup page 2 155
session bean client machine 9 66
authenticate preemptively soap ui option 3 170
javax.naming.NameNotFoundException: Name ... is not bound in this Context. 6 363
Enabling the Skype for Business Meeting Scheduler in Hybrid OWA
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

756 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