1 5 6 package com.raptus.owxv3.eadmin; 7 8 import java.io.*; 9 10 import javax.servlet.ServletException ; 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 43 public class EASessionTimeoutAction extends OmniaWebAction 44 { 45 47 62 public ActionForward perform(ActionMapping mapping, 63 ActionForm form, 64 HttpServletRequest request, 65 HttpServletResponse response) 66 throws IOException, ServletException 67 { 68 HttpSession session = request.getSession(); 69 User user= checkForUserInSession(session); 70 71 response.setContentType("text/plain"); 73 PrintWriter toClient=response.getWriter(); 74 75 String FLASH_PARAM_TOTAL_TIME="totaltime"; 76 String 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 ().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 | Popular Tags |