Solved

Refresh the page and using session.

Posted on 2004-04-04
16
3,516 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
reflections, dynamic class loading 3 83
squirrelPlay java challenge 40 160
main method of string class 3 123
listing all functions in JavaScript 19 252
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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