You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Caroline Jen <ji...@yahoo.com> on 2003/11/03 07:23:35 UTC

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


Re: Session Times Out

Posted by Vinayak Birari <vi...@onwardgroup.com>.
hi,
you can inform the user by using the request object
bind ur message by :
request.setAttribute("messageName", "session timed out!!");
retrieve the message by  : request.getAttribute("messageName");
hope this helps u.
regards,
Vinayak.

----- Original Message ----- 
From: "Caroline Jen" <ji...@yahoo.com>
To: <st...@jakarta.apache.org>
Sent: Monday, November 03, 2003 11:53 AM
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
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Session Times Out

Posted by Amit Kumar Sharma <am...@sysarris.soft.net>.
if session becomes null than try this

if ( session.getValue("SESSIONNAME")==null ){%>
		<script language="JavaScript">
			window.open("Index.jsp",fullscreen="yes");
			parent.close();
			//winself = window.self;
			//winself.setTimeout("window.close()",1);
		</script>
		<%
}

try this and than U can set one more attritbute(Flag) which on the Index
page can show a message that the user is here because of timeout.


Regards,
Amit Kumar Sharma
SysArris Software Pvt Ltd
120A, Elephant Rock Road,
3rd Block, Jayanagar,Bangalore - 560011
Tel.: 91-80-665 4965 / 665 5052
amit.ks@sysarris.soft.net <ma...@sysarris.soft.net> 
  


-----Original Message-----
From: Caroline Jen [mailto:jiapei_jen@yahoo.com]
Sent: Monday, November 03, 2003 11:54 AM
To: struts-user@jakarta.apache.org
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

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Session Times Out

Posted by MB...@cpaglobal.com.
Yeah, you would do it in both places.

In the jsp when you access it directly, and in the action.

Mike



|---------+---------------------------->
|         |           "Jose Ramon Diaz"|
|         |           <jose.diaz@aranza|
|         |           di.es>           |
|         |                            |
|         |           03/11/2003 10:06 |
|         |           AM               |
|         |           Please respond to|
|         |           "Struts Users    |
|         |           Mailing List"    |
|---------+---------------------------->
  >------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                              |
  |       To:       "'Struts Users Mailing List'" <st...@jakarta.apache.org>                                               |
  |       cc:                                                                                                                    |
  |       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 :
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP
> Tag Library
> 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
> <taglib>
>       <tlibversion>1.0</tlibversion>
>       <jspversion>1.1</jspversion>
>       <shortname>Tag Libs</shortname>
>       <info>ustom Tags</info>
>       <tag>
>             <name>checkLogin</name>
>
> <tagclass>com.cpaglobal.cpadirect.tag.CheckLogin</tagclass>
>             <bodycontent>empty</bodycontent>
>             <info>Checks the login status of a user and
> forward them to the
> login page if not logged in.</info>
>             <attribute>
>                   <name>loginPage</name>
>                   <required>false</required>
>                   <rtexprvalue>false</rtexprvalue>
>             </attribute>
>             <attribute>
>                   <name>default</name>
>                   <required>false</required>
>                   <rtexprvalue>false</rtexprvalue>
>             </attribute>
>       </tag>
> </taglib>
>
>
>
> 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 = "/JSP/Timeout.jsp";
>
>
>       public void setLoginPage(String loginPage) {
>             this.loginPage = loginPage;
>       }
>
>       public int doStartTag() throws JspException {
>          return (SKIP_BODY);
>       }
>
>       public int doEndTag() {
>             try {
>                   HttpSession session = pageContext.getSession();
>                   if (session != null) {
>                         User user = (User)
> session.getAttribute(SessionVariables.SESSION_LOGGED_ON_USER);
>                         if (user == 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="/WEB-INF/cpa.tld" prefix="cpa"%>
> <cpa:checkLogin/>
>
> Mike
>
>
>
>
> |---------+---------------------------->
> |         |           Caroline Jen     |
> |         |           <jiapei_jen@yahoo|
> |         |           .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


RE: Session Times Out

Posted by Jose Ramon Diaz <jo...@aranzadi.es>.
 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 :
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP
> Tag Library
> 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
> <taglib>
>       <tlibversion>1.0</tlibversion>
>       <jspversion>1.1</jspversion>
>       <shortname>Tag Libs</shortname>
>       <info>ustom Tags</info>
>       <tag>
>             <name>checkLogin</name>
>
> <tagclass>com.cpaglobal.cpadirect.tag.CheckLogin</tagclass>
>             <bodycontent>empty</bodycontent>
>             <info>Checks the login status of a user and
> forward them to the
> login page if not logged in.</info>
>             <attribute>
>                   <name>loginPage</name>
>                   <required>false</required>
>                   <rtexprvalue>false</rtexprvalue>
>             </attribute>
>             <attribute>
>                   <name>default</name>
>                   <required>false</required>
>                   <rtexprvalue>false</rtexprvalue>
>             </attribute>
>       </tag>
> </taglib>
>
>
>
> 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 = "/JSP/Timeout.jsp";
>
>
>       public void setLoginPage(String loginPage) {
>             this.loginPage = loginPage;
>       }
>
>       public int doStartTag() throws JspException {
>          return (SKIP_BODY);
>       }
>
>       public int doEndTag() {
>             try {
>                   HttpSession session = pageContext.getSession();
>                   if (session != null) {
>                         User user = (User)
> session.getAttribute(SessionVariables.SESSION_LOGGED_ON_USER);
>                         if (user == 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="/WEB-INF/cpa.tld" prefix="cpa"%>
> <cpa:checkLogin/>
>
> Mike
>
>
>
>
> |---------+---------------------------->
> |         |           Caroline Jen     |
> |         |           <jiapei_jen@yahoo|
> |         |           .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


Re: Session Times Out

Posted by MB...@cpaglobal.com.




Make a custom tag like so :



Create a tld file with this in  it :

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library
1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
      <tlibversion>1.0</tlibversion>
      <jspversion>1.1</jspversion>
      <shortname>Tag Libs</shortname>
      <info>ustom Tags</info>
      <tag>
            <name>checkLogin</name>
            <tagclass>com.cpaglobal.cpadirect.tag.CheckLogin</tagclass>
            <bodycontent>empty</bodycontent>
            <info>Checks the login status of a user and forward them to the
login page if not logged in.</info>
            <attribute>
                  <name>loginPage</name>
                  <required>false</required>
                  <rtexprvalue>false</rtexprvalue>
            </attribute>
            <attribute>
                  <name>default</name>
                  <required>false</required>
                  <rtexprvalue>false</rtexprvalue>
            </attribute>
      </tag>
</taglib>



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 = "/JSP/Timeout.jsp";


      public void setLoginPage(String loginPage) {
            this.loginPage = loginPage;
      }

      public int doStartTag() throws JspException {
         return (SKIP_BODY);
      }

      public int doEndTag() {
            try {
                  HttpSession session = pageContext.getSession();
                  if (session != null) {
                        User user = (User)
session.getAttribute(SessionVariables.SESSION_LOGGED_ON_USER);
                        if (user == 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="/WEB-INF/cpa.tld" prefix="cpa"%>
<cpa:checkLogin/>

Mike




|---------+---------------------------->
|         |           Caroline Jen     |
|         |           <jiapei_jen@yahoo|
|         |           .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


RE: Session Times Out

Posted by Amit Kumar Sharma <am...@sysarris.soft.net>.
if session becomes null than try this

if ( session.getValue("SESSIONNAME")==null ){%>
		<script language="JavaScript">
			window.open("Index.jsp",fullscreen="yes");
			parent.close();
			//winself = window.self;
			//winself.setTimeout("window.close()",1);
		</script>
		<%
}

try this and than U can set one more attritbute(Flag) which on the Index
page can show a message that the user is here because of timeout.

Regards,
Amit Kumar Sharma
SysArris Software Pvt Ltd
120A, Elephant Rock Road,
3rd Block, Jayanagar,Bangalore - 560011
Tel.: 91-80-665 4965 / 665 5052
amit.ks@sysarris.soft.net <ma...@sysarris.soft.net>



-----Original Message-----
From: Caroline Jen [mailto:jiapei_jen@yahoo.com]
Sent: Monday, November 03, 2003 11:54 AM
To: struts-user@jakarta.apache.org
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


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org