[Opensource] Forward to another jsp if session timeout
Eddie Lewis
ELewis at copyright.com.au
Wed Sep 25 16:36:50 PDT 2002
Hi Ken
This may help
We co-ordinate the session timeout on the server (using tomcat) with the jsp
page timeout
for tomcat - set the connectionTimeout value in the server.xml file
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="80" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="60000"/>
<!-- Note : To disable connection timeouts, set connectionTimeout value
to -1 -->
we created an include file with one line
<meta http-equiv="refresh"
content="1800;URL=/expresso/cal/SessionTimeout.do?state=timeout">
content is the time (i.e. 30 minutes above)
Include this file in your jsp
When the 30 minute inactive time is reached, then the session object on the
server will also have invalidated.
Simply make the above servlet accessible to anybody (ass the session details
will be invalid) and call a generic timeout script on the server
SessionTimeout.java
public class SessionTimeoutCont extends DBControllerExt
{
public SessionTimeoutCont()
{
super();
State timeout = new State("timeout", "Process a timeout");
addState(timeout);
}
public String getTitle()
{
return new String("Our Session Timeout Controller");
}
protected void runTimeoutState(ControllerRequest request,
ControllerResponse response) throws ControllerException
{
/*
* in the request object add params
* errormsg
* formaction - i.e /cal/CcsExpress.do
* tostate - DONT add if you want to go to the main page by default
* error - simply include this if this is an error - else is success
message
* i.e. repquest.setParameter("error", "true")
*/
String myName=thisClass+"runTimeoutState() ";
try
{
request.setParameter("formaction", DefaultParams.sHomeCont);
request.setParameter("tostate", "homePage");
request.setParameter("error", "true");
String sMsg = "<div align=\"center\">Your session has remained
inactive for " +
DefaultParams.iSessionTimeout + " minutes<br>" +
"and you have been timed out.<br><br>" +
"Please login again to continue.</div>";
request.setParameter("errormsg", sMsg);
Transition outcome = new Transition();
outcome.addParam("state", "outcome");
outcome.addParam("controller", DefaultParams.sContPkg +
"OutcomeCont");
outcome.transition(request,response);
}
catch (Exception dbe) {
throw new ControllerException(
myName+ "Session Timeout Controller exception: "
+dbe.getMessage());
}
}
}
We simply have a jsp that displays the above message and creates the
transition (Back to a home page to login again ??)
Good luck
Eddie Lewis
-----Original Message-----
From: Innovest Ken [mailto:innovest_11 at yahoo.com]
Sent: Wednesday, 25 September 2002 12:33 PM
To: opensource at jcorporate.com
Subject: [Opensource] Forward to another jsp if session timeout
hi all,
If session timeout, I need to forward to another jsp.
Currently, I check at all the individual jsp and all
controller. Instead of putting the codes in all the
states in all controllers, I put the codes in newstate
of the controller, so that all states will also do the
check. But to forward to the jsp, I need controller
response, so I'm stuck here.
Any other way to forward to jsp?
Thanks
Innovest
__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
_______________________________________________
Opensource mailing list
Opensource at jcorporate.com
http://mail.jcorporate.com/mailman/listinfo/opensource
Archives: http://mail.jcorporate.com/pipermail/opensource/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.jcorporate.com/pipermail/opensource/attachments/20020926/3df92cdc/attachment-0002.htm
More information about the Opensource
mailing list