KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > eadmin > EASessionTimeoutAction


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.eadmin;
7
8 import java.io.*;
9
10 import javax.servlet.ServletException JavaDoc;
11 import javax.servlet.http.*;
12
13 import org.apache.struts.action.*;
14
15 import com.raptus.owxv3.api.OmniaWebAction;
16 import com.raptus.owxv3.api.usermgr.User;
17
18 /**
19  * Handles the menufunctions and its bean.
20  *
21  * <hr>
22  * <table width="100%" border="0">
23  * <tr>
24  * <td width="24%"><b>Filename</b></td><td width="76%">EASessionTimeoutAction.java</td>
25  * </tr>
26  * <tr>
27  * <td width="24%"><b>Author</b></td><td width="76%">REEA</td>
28  * </tr>
29  * <tr>
30  * <td width="24%"><b>Date</b></td><td width="76%">16th of October 2001</td>
31  * </tr>
32  * </table>
33  * <hr>
34  * <table width="100%" border="0">
35  * <tr>
36  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
37  * </tr>
38  * </table>
39  * <hr>
40  * Class that is called from flash that shows the actual time remaining in the session.
41  *
42  */

43 public class EASessionTimeoutAction extends OmniaWebAction
44 {
45     // --------------------------------------------------------- Public Methods
46

47     /**
48      * Process the specified HTTP request, and create the corresponding HTTP
49      * response (or forward to another web component that will create it).
50      * Return an <code>ActionForward</code> instance describing where and how
51      * control should be forwarded, or <code>null</code> if the response has
52      * already been completed.
53      *
54      * @param mapping The ActionMapping used to select this instance
55      * @param actionForm The optional ActionForm bean for this request (if any)
56      * @param request The HTTP request we are processing
57      * @param response The HTTP response we are creating
58      *
59      * @exception IOException if an input/output error occurs
60      * @exception ServletException if a servlet exception occurs
61      */

62     public ActionForward perform(ActionMapping mapping,
63                  ActionForm form,
64                  HttpServletRequest request,
65                  HttpServletResponse response)
66     throws IOException, ServletException JavaDoc
67     {
68         HttpSession session = request.getSession();
69         User user= checkForUserInSession(session);
70
71         //response.setContentType("application/x-www-urlform-encoded");
72
response.setContentType("text/plain");
73         PrintWriter toClient=response.getWriter();
74
75         String JavaDoc FLASH_PARAM_TOTAL_TIME="totaltime";
76         String JavaDoc FLASH_PARAM_REMAIN_TIME="remaintime";
77
78         if(user == null)
79         {
80
81             toClient.print(FLASH_PARAM_TOTAL_TIME);
82             toClient.print("=");
83             toClient.print(session.getMaxInactiveInterval());
84
85             toClient.print("&");
86             toClient.print(FLASH_PARAM_REMAIN_TIME);
87             toClient.print("=0");
88
89
90
91         }
92         else
93         {
94
95             toClient.print(FLASH_PARAM_TOTAL_TIME);
96             toClient.print("=");
97             toClient.print(session.getMaxInactiveInterval());
98
99             long creationtime=session.getLastAccessedTime();
100             long curenttime= new java.util.Date JavaDoc().getTime();
101             int diference=(int)((curenttime-creationtime)/1000);
102
103             toClient.print("&");
104             toClient.print(FLASH_PARAM_REMAIN_TIME);
105             toClient.print("=");
106             int remaintime=session.getMaxInactiveInterval()-diference;
107             if(remaintime<0) remaintime=0;
108             toClient.print(remaintime);
109         }
110         toClient.close();
111         return null;
112     }
113
114
115 }
116
117 // eof
118
Popular Tags