why not just use a respond.sendRedirect?  that will behave as you like.

if(session.isNew()){
        session.invalidate();

response.sendRedirect(response.encodeRedirectURL("/SS30/default.jsp")) ;

-----Original Message-----
From: Raghavendra i Rao [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 26, 2000 12:03 PM
To: [EMAIL PROTECTED]
Subject: Re: Session timeout


I implemented the following one with the setMaxInactiveinterval(600) and the
rquest dispatcher to redirect the URL. But I have a small problem here.The
redirection does not change the URL in the browser. It remains the same. i.e
I have my redirection code in TestSesion.jsp(URL :
http://localhost:7001/TestSession.jsp). And it redirects to login.html. But
after it redirects the login.html page comes up but the URL is
still(http://localhost:7001/TestSession.jsp). Please let me know if I am
missing something here. The code in TestSession.jsp is very simple and as
follows..

<%
  session = request.getSession(false);

  if(session.getAttribute("id") == null)
  {
    RequestDispatcher dispatcher =
request.getRequestDispatcher("login.html");
   if (dispatcher != null) {
     dispatcher.forward(request, response);
  }

}
else
 System.out.println("The session is not null");

%>

Thanks.

------------- Original Message --------------
Scott Evans <[EMAIL PROTECTED]> wrote:
To:[EMAIL PROTECTED]
From:Scott Evans <[EMAIL PROTECTED]>
Date:Wed, 26 Jul 2000 11:58:09 +0200
Subject: Re: Session timeout

Sorry, but I don't think Javascript has anything to do with it.

The amount of time for a session to timeout is specified in the server's
configuration. For the Tomcat container in server.xml:

        <Context path="/examples" docBase="examples"
            defaultSessionTimeOut="30" isWARExpanded="true"
            isWARValidated="false" isInvokerEnabled="true"
            isWorkDirPersistent="false"/>

In this case the session will time out after it has been idle for 30
minutes. If you change defaultSessionTimeOut to 15 it will be 15 minutes.

Then in your servlet/jsp you can do something like this:

// true specifies to create a session if one doesn't already exist for the
user
// you could also specify false and then test if session is null in the if
statement
// if you want the login page to create the session
HttpSession session = request.getSession(true);

// the session is new if the client doesn't know about it yet
if (session.isNew()) {

        // use a RequestDispatcher to forward the request
        // don't use sendRedirect to avoid another roundtrip to the client
and back
        RequestDispatcher dispatcher =
request.getRequestDispatcher("/jsp/login.jsp");

        // dispatcher may be null if the container can't find the file
specified
        if (dispatcher != null) {
                dispatcher.forward(request, response);
        }
        else {
                // go to your error page
        }
}

You can also specify the amount of time for a session to timeout
programmatically using the following:

HttpSession session = request.getSession(true);
// specify the amount of idle seconds until this session will timeout
session.setMaxInactiveInterval(15 * 60); // 15 minutes * 60 seconds

Scott Evans


-----Original Message-----
From: Suriya Narayan Varatharajan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 26, 2000 6:34 AM
To: [EMAIL PROTECTED]
Subject: Re: Session timeout


well... really it a good question...
do onething...
Use javascript...
in javascript... we have setTimeOut function...
it will take two parameter... one is function name,other is time..
set the time...
if it is exist... clear the session value...
and chk if it is clear go to the first page...


regards
suriya
*Q  try for everything     Q*

Suriya narayanan V
Software Engineer
Contech Software Ltd
E-3/1,2,3, GIDC Electronics Estate,
Sector - 25, Gandhinagar - 382 044, INDIA
Tel.    : +91(2712) 44989/43324/43328
    (R)  : 91 - 79 - 6746164
fax    :+91 (2712) 24468

Email         :[EMAIL PROTECTED],[EMAIL PROTECTED]
URL           : http://www.contechgroup.com
HomePage :     http://www.suriyan.org



-----Original Message-----
From:   Raghavendra i Rao [SMTP:[EMAIL PROTECTED]]
Sent:   Wednesday, July 26, 2000 8:49 AM
To:     [EMAIL PROTECTED]
Subject:        Session timeout

How can I timeout a session using JSPs ?? i.e if the User is initially logs
into my web site and then is idle for 15 minutes I want to timeout his
sesion .After the timeout, if the User clicks on anything on the existing
page I want to redirect him to the Login page of the application.  Also if
he goes back in the browser (Using the Back button) I do not want to allow
him to do that. I am quite new to JSP and hence any help will be highly
appreciated.
Thanks in advance.


_________________________________________________
Get Your Free Email At, http://www.rediffmail.com

Partcipate in crazy Re.1 auctions at http://www.rediff.com/auctions

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

_________________________________________________
Get Your Free Email At, http://www.rediffmail.com

Partcipate in crazy Re.1 auctions at http://www.rediff.com/auctions

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to