Session information for the web application at the specified context path. Displays a profile of session thisAccessedTime listing number of sessions for each 10 minute interval up to 10 hours. @param writer Writer to render to @param cn Name of the application to list session information fo
(PrintWriter writer, ContextName cn, int idle, StringManager smClient)
| 1220 | * @param smClient i18n support for current client's locale |
| 1221 | */ |
| 1222 | protected void sessions(PrintWriter writer, ContextName cn, int idle, StringManager smClient) { |
| 1223 | |
| 1224 | if (debug >= 1) { |
| 1225 | log("sessions: Session information for web application '" + cn + "'"); |
| 1226 | if (idle >= 0) { |
| 1227 | log("sessions: Session expiration for " + idle + " minutes '" + cn + "'"); |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | if (!validateContextName(cn, writer, smClient)) { |
| 1232 | return; |
| 1233 | } |
| 1234 | |
| 1235 | String displayPath = cn.getDisplayName(); |
| 1236 | |
| 1237 | try { |
| 1238 | Context context = (Context) host.findChild(cn.getName()); |
| 1239 | if (context == null) { |
| 1240 | writer.println(smClient.getString("managerServlet.noContext", Escape.htmlElementContent(displayPath))); |
| 1241 | return; |
| 1242 | } |
| 1243 | Manager manager = context.getManager(); |
| 1244 | if (manager == null) { |
| 1245 | writer.println(smClient.getString("managerServlet.noManager", Escape.htmlElementContent(displayPath))); |
| 1246 | return; |
| 1247 | } |
| 1248 | int maxCount = 60; |
| 1249 | int histoInterval = 1; |
| 1250 | int maxInactiveInterval = context.getSessionTimeout(); |
| 1251 | if (maxInactiveInterval > 0) { |
| 1252 | histoInterval = maxInactiveInterval / maxCount; |
| 1253 | if (histoInterval * maxCount < maxInactiveInterval) { |
| 1254 | histoInterval++; |
| 1255 | } |
| 1256 | if (0 == histoInterval) { |
| 1257 | histoInterval = 1; |
| 1258 | } |
| 1259 | maxCount = maxInactiveInterval / histoInterval; |
| 1260 | if (histoInterval * maxCount < maxInactiveInterval) { |
| 1261 | maxCount++; |
| 1262 | } |
| 1263 | } |
| 1264 | |
| 1265 | writer.println(smClient.getString("managerServlet.sessions", displayPath)); |
| 1266 | writer.println(smClient.getString("managerServlet.sessiondefaultmax", "" + maxInactiveInterval)); |
| 1267 | Session[] sessions = manager.findSessions(); |
| 1268 | int[] timeout = new int[maxCount + 1]; |
| 1269 | int notimeout = 0; |
| 1270 | int expired = 0; |
| 1271 | for (Session session : sessions) { |
| 1272 | int time = (int) (session.getIdleTimeInternal() / 1000L); |
| 1273 | if (idle >= 0 && time >= idle * 60) { |
| 1274 | session.expire(); |
| 1275 | expired++; |
| 1276 | } |
| 1277 | time = time / 60 / histoInterval; |
| 1278 | if (time < 0) { |
| 1279 | notimeout++; |
no test coverage detected