MCPcopy Create free account
hub / github.com/apache/tomcat / sessions

Method sessions

java/org/apache/catalina/manager/ManagerServlet.java:1222–1312  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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++;

Callers 1

expireSessionsMethod · 0.95

Calls 15

validateContextNameMethod · 0.95
htmlElementContentMethod · 0.95
getManagerMethod · 0.95
getSessionTimeoutMethod · 0.95
findSessionsMethod · 0.95
handleThrowableMethod · 0.95
logMethod · 0.65
getDisplayNameMethod · 0.65
findChildMethod · 0.65
getNameMethod · 0.65
getStringMethod · 0.65
getIdleTimeInternalMethod · 0.65

Tested by

no test coverage detected