Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@www.apache.org Received: (qmail 71903 invoked from network); 3 Nov 2003 10:19:18 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 3 Nov 2003 10:19:18 -0000 Received: (qmail 48106 invoked by uid 500); 3 Nov 2003 10:18:38 -0000 Delivered-To: apmail-jakarta-struts-user-archive@jakarta.apache.org Received: (qmail 47861 invoked by uid 500); 3 Nov 2003 10:18:36 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 47846 invoked from network); 3 Nov 2003 10:18:35 -0000 Received: from unknown (HELO gmexchange1.int.teb.com.tr) (213.148.68.5) by daedalus.apache.org with SMTP; 3 Nov 2003 10:18:35 -0000 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-9" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 Subject: RE: Session Times Out Date: Mon, 3 Nov 2003 12:20:03 +0200 Message-ID: <0FE1A54E2CB67647B1F38F00F4B912B804B22FED@gmexchange1.int.teb.com.tr> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Session Times Out Thread-Index: AcOh8snf5rPfyx13SN2PTt5SXG4iBAAALDcw From: "Seyhan BASMACI (Internet Yazilimlari Yetkilisi)" To: "Struts Users Mailing List" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I think best way to check session is to extend requestProcessor Class = and override processPath method, -----Original Message----- From: Jose Ramon Diaz [mailto:jose.diaz@aranzadi.es] Sent: Monday, November 03, 2003 12:06 PM To: 'Struts Users Mailing List' Subject: RE: Session Times Out Hi, But be carefull because the actions will be executed before redirecting = to JSP, so I think it?s better to check the session in all the actions, = isn?t it? > > Make a custom tag like so : > > > > Create a tld file with this in it : > > > Tag Library > 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> > > 1.0 > 1.1 > Tag Libs > ustom Tags > > checkLogin > > com.cpaglobal.cpadirect.tag.CheckLogin > empty > Checks the login status of a user and > forward them to the > login page if not logged in. > > loginPage > false > false > > > default > false > false > > > > > > > Code for the custom tag : > > package com.cpaglobal.cpadirect.tag; > > import java.io.IOException; > > import javax.servlet.ServletException; > import javax.servlet.http.HttpSession; > import javax.servlet.jsp.JspException; > import javax.servlet.jsp.tagext.TagSupport; > > import com.cpaglobal.cpadirect.applicationlogic.SessionVariables; > import com.cpaglobal.cpadirect.applicationlogic.User; > > > public class CheckLogin extends TagSupport { > > > private String loginPage =3D "/JSP/Timeout.jsp"; > > > public void setLoginPage(String loginPage) { > this.loginPage =3D loginPage; > } > > public int doStartTag() throws JspException { > return (SKIP_BODY); > } > > public int doEndTag() { > try { > HttpSession session =3D pageContext.getSession(); > if (session !=3D null) { > User user =3D (User) > session.getAttribute(SessionVariables.SESSION_LOGGED_ON_USER); > if (user =3D=3D null) { > pageContext.forward(loginPage); > return (SKIP_PAGE); > } > } else { > pageContext.forward(loginPage); > return (SKIP_PAGE); > } > } catch(ServletException e) { > new JspException(e.toString()); > } catch(IOException e) { > new JspException(e.toString()); > } > return (EVAL_PAGE); > } > > } > > How to use it : > > <%@ taglib uri=3D"/WEB-INF/cpa.tld" prefix=3D"cpa"%> > > > Mike > > > > > |---------+----------------------------> > | | Caroline Jen | > | | | | .com> | > | | | > | | 03/11/2003 06:23 | > | | AM | > | | Please respond to| > | | "Struts Users | > | | Mailing List" | > |---------+----------------------------> > > >------------------------------------------------------------- > -----------------------------------------------------------------| > | > | > | To: struts-user@jakarta.apache.org > | > | cc: > | > | Subject: Session Times Out > | > > >------------------------------------------------------------- > -----------------------------------------------------------------| > > > > > I check if session expires for each action in the > application. If the session times out, I forward the > user to index.jsp so that the user can log on again. > > How do I inform the user with a message that he/she is > at the welcome page because the session has expired? > > __________________________________ > Do you Yahoo!? > Exclusive Video Premiere - Britney Spears > http://launch.yahoo.com/promos/britneyspears/ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: struts-user-help@jakarta.apache.org > > > > > > > > ************************************************************** > ****************** > The information in this message is confidential and may be legally > privileged. It is intended solely for the addressee; access to this > email by anyone else is unauthorised. > > If you are not the intended recipient: (1) you are kindly requested > to return a copy of this message to the sender indicating that you > have received it in error, and to destroy the received copy; and (2) > any disclosure or distribution of this message, as well as any action > taken or omitted to be taken in reliance on its content, is prohibited > and may be unlawful. > ************************************************************** > ****************** > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: struts-user-help@jakarta.apache.org > > > --------------------------------------------------------------------- To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: struts-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: struts-user-help@jakarta.apache.org