protected static final String APPLICATION_MESSAGE = "message";
protected static final String APPLICATION_ERROR = "error";
- protected static final String NONCE_SESSION =
- "org.apache.catalina.manager.NONCE";
- protected static final String NONCE_REQUEST = "nonce";
-
protected static final String sessionsListJspPath = "/WEB-INF/jsp/sessionsList.jsp";
protected static final String sessionDetailJspPath = "/WEB-INF/jsp/sessionDetail.jsp";
String deployPath = request.getParameter("deployPath");
String deployConfig = request.getParameter("deployConfig");
String deployWar = request.getParameter("deployWar");
- String requestNonce = request.getParameter(NONCE_REQUEST);
// Prepare our output writer to generate the response message
response.setContentType("text/html; charset=" + Constants.CHARSET);
String message = "";
- // Check nonce
- // There *must* be a nonce in the session before any POST is processed
- HttpSession session = request.getSession();
- String sessionNonce = (String) session.getAttribute(NONCE_SESSION);
- if (sessionNonce == null) {
- message = sm.getString("htmlManagerServlet.noNonce", command);
- // Reset the command
- command = null;
- } else {
- if (!sessionNonce.equals(requestNonce)) {
- // Nonce mis-match.
- message =
- sm.getString("htmlManagerServlet.nonceMismatch", command);
- // Reset the command
- command = null;
- }
- }
-
if (command == null || command.length() == 0) {
// No command == list
// List always displayed -> do nothing
log("list: Listing contexts for virtual host '" +
host.getName() + "'");
- String newNonce = generateNonce();
- request.getSession().setAttribute(NONCE_SESSION, newNonce);
-
PrintWriter writer = response.getWriter();
// HTML Header Section
Map.Entry<String,String> entry = iterator.next();
String displayPath = entry.getKey();
String contextPath = entry.getValue();
- Context context = (Context) host.findChild(contextPath);
+ Context ctxt = (Context) host.findChild(contextPath);
if (displayPath.equals("")) {
displayPath = "/";
}
- if (context != null ) {
+ if (ctxt != null ) {
try {
isDeployed = isDeployed(contextPath);
} catch (Exception e) {
args = new Object[7];
args[0] = URL_ENCODER.encode(displayPath);
args[1] = displayPath;
- args[2] = context.getDisplayName();
+ args[2] = ctxt.getDisplayName();
if (args[2] == null) {
args[2] = " ";
}
- args[3] = new Boolean(context.getAvailable());
+ args[3] = new Boolean(ctxt.getAvailable());
args[4] = response.encodeURL
(request.getContextPath() +
"/html/sessions?path=" + URL_ENCODER.encode(displayPath));
- if (context.getManager() != null) {
+ if (ctxt.getManager() != null) {
args[5] = new Integer
- (context.getManager().getActiveSessions());
+ (ctxt.getManager().getActiveSessions());
} else {
args[5] = new Integer(0);
}
writer.print
(MessageFormat.format(APPS_ROW_DETAILS_SECTION, args));
- args = new Object[15];
+ args = new Object[14];
args[0] = response.encodeURL
(request.getContextPath() +
"/html/start?path=" + URL_ENCODER.encode(displayPath));
"/html/expire?path=" + URL_ENCODER.encode(displayPath));
args[9] = appsExpire;
args[10] = sm.getString("htmlManagerServlet.expire.explain");
- Manager manager = context.getManager();
+ Manager manager = ctxt.getManager();
if (manager == null) {
args[11] = sm.getString("htmlManagerServlet.noManager");
} else {
args[11] = new Integer(
- context.getManager().getMaxInactiveInterval()/60);
+ ctxt.getManager().getMaxInactiveInterval()/60);
}
args[12] = sm.getString("htmlManagerServlet.expire.unit");
args[13] = highlightColor;
- args[14] = newNonce;
- if (context.getPath().equals(this.context.getPath())) {
+ if (ctxt.getPath().equals(this.context.getPath())) {
writer.print(MessageFormat.format(
MANAGER_APP_ROW_BUTTON_SECTION, args));
- } else if (context.getAvailable() && isDeployed) {
+ } else if (ctxt.getAvailable() && isDeployed) {
writer.print(MessageFormat.format(
STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTION, args));
- } else if (context.getAvailable() && !isDeployed) {
+ } else if (ctxt.getAvailable() && !isDeployed) {
writer.print(MessageFormat.format(
STARTED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION, args));
- } else if (!context.getAvailable() && isDeployed) {
+ } else if (!ctxt.getAvailable() && isDeployed) {
writer.print(MessageFormat.format(
STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION, args));
} else {
}
// Deploy Section
- args = new Object[8];
+ args = new Object[7];
args[0] = sm.getString("htmlManagerServlet.deployTitle");
args[1] = sm.getString("htmlManagerServlet.deployServer");
args[2] = response.encodeURL(request.getContextPath() + "/html/deploy");
args[4] = sm.getString("htmlManagerServlet.deployConfig");
args[5] = sm.getString("htmlManagerServlet.deployWar");
args[6] = sm.getString("htmlManagerServlet.deployButton");
- args[7] = newNonce;
writer.print(MessageFormat.format(DEPLOY_SECTION, args));
- args = new Object[5];
+ args = new Object[4];
args[0] = sm.getString("htmlManagerServlet.deployUpload");
args[1] = response.encodeURL(request.getContextPath() + "/html/upload");
args[2] = sm.getString("htmlManagerServlet.deployUploadFile");
args[3] = sm.getString("htmlManagerServlet.deployButton");
- args[4] = newNonce;
writer.print(MessageFormat.format(UPLOAD_SECTION, args));
// Diagnostics section
- args = new Object[6];
+ args = new Object[5];
args[0] = sm.getString("htmlManagerServlet.diagnosticsTitle");
args[1] = sm.getString("htmlManagerServlet.diagnosticsLeak");
args[2] = response.encodeURL(
request.getContextPath() + "/html/findleaks");
- args[3] = newNonce;
- args[4] = sm.getString("htmlManagerServlet.diagnosticsLeakWarning");
- args[5] = sm.getString("htmlManagerServlet.diagnosticsLeakButton");
+ args[3] = sm.getString("htmlManagerServlet.diagnosticsLeakWarning");
+ args[4] = sm.getString("htmlManagerServlet.diagnosticsLeakButton");
writer.print(MessageFormat.format(DIAGNOSTICS_SECTION, args));
// Server Header Section
String searchPath = path;
if( path.equals("/") )
searchPath = "";
- Context context = (Context) host.findChild(searchPath);
- if (null == context) {
+ Context ctxt = (Context) host.findChild(searchPath);
+ if (null == ctxt) {
throw new IllegalArgumentException(sm.getString("managerServlet.noContext",
RequestUtil.filter(path)));
}
- Session[] sessions = context.getManager().findSessions();
+ Session[] sessions = ctxt.getManager().findSessions();
return sessions;
}
protected Session getSessionForPathAndId(String path, String id) throws IOException {
String searchPath = path;
if( path.equals("/") )
searchPath = "";
- Context context = (Context) host.findChild(searchPath);
- if (null == context) {
+ Context ctxt = (Context) host.findChild(searchPath);
+ if (null == ctxt) {
throw new IllegalArgumentException(sm.getString("managerServlet.noContext",
RequestUtil.filter(path)));
}
- Session session = context.getManager().findSession(id);
+ Session session = ctxt.getManager().findSession(id);
return session;
}
resp.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); // HTTP 1.1
resp.setDateHeader("Expires", 0); // 0 means now
req.setAttribute("currentSession", session);
- getServletContext().getRequestDispatcher(sessionDetailJspPath).include(req, resp);
+ getServletContext().getRequestDispatcher(resp.encodeURL(sessionDetailJspPath)).include(req, resp);
}
/**
" <td class=\"row-left\" bgcolor=\"{6}\" rowspan=\"2\"><small>{2}</small></td>\n" +
" <td class=\"row-center\" bgcolor=\"{6}\" rowspan=\"2\"><small>{3}</small></td>\n" +
" <td class=\"row-center\" bgcolor=\"{6}\" rowspan=\"2\">" +
- "<small><a href=\"{4}\" target=\"_blank\">{5}</a></small></td>\n";
+ "<small><a href=\"{4}\">{5}</a></small></td>\n";
private static final String MANAGER_APP_ROW_BUTTON_SECTION =
" <td class=\"row-left\" bgcolor=\"{13}\">\n" +
" <td class=\"row-left\" bgcolor=\"{13}\">\n" +
" <form method=\"POST\" action=\"{8}\">\n" +
" <small>\n" +
- " <input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{14}\">" +
" <input type=\"submit\" value=\"{9}\"> {10} <input type=\"text\" name=\"idle\" size=\"5\" value=\"{11}\"> {12} \n" +
" </small>\n" +
" </form>\n" +
" <td class=\"row-left\" bgcolor=\"{13}\">\n" +
" <small>{1}</small> \n" +
" <form class=\"inline\" method=\"POST\" action=\"{2}\">" +
- " <input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{14}\">" +
" <small><input type=\"submit\" value=\"{3}\"></small>" +
" </form>\n" +
" <form class=\"inline\" method=\"POST\" action=\"{4}\">" +
- " <input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{14}\">" +
" <small><input type=\"submit\" value=\"{5}\"></small>" +
" </form>\n" +
" <form class=\"inline\" method=\"POST\" action=\"{6}\">" +
- " <input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{14}\"" +
" <small><input type=\"submit\" value=\"{7}\"></small>" +
" </form>\n" +
" </td>\n" +
" <td class=\"row-left\" bgcolor=\"{13}\">\n" +
" <form method=\"POST\" action=\"{8}\">\n" +
" <small>\n" +
- " <input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{14}\">" +
" <input type=\"submit\" value=\"{9}\"> {10} <input type=\"text\" name=\"idle\" size=\"5\" value=\"{11}\"> {12} \n" +
" </small>\n" +
" </form>\n" +
private static final String STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION =
" <td class=\"row-left\" bgcolor=\"{13}\" rowspan=\"2\">\n" +
" <form class=\"inline\" method=\"POST\" action=\"{0}\">" +
- " <input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{14}\">" +
" <small><input type=\"submit\" value=\"{1}\"></small>" +
" </form>\n" +
" <small>{3}</small> \n" +
" <small>{5}</small> \n" +
" <form class=\"inline\" method=\"POST\" action=\"{6}\">" +
- " <input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{14}\">" +
" <small><input type=\"submit\" value=\"{7}\"></small>" +
" </form>\n" +
" </td>\n" +
" <td class=\"row-left\" bgcolor=\"{13}\" rowspan=\"2\">\n" +
" <small>{1}</small> \n" +
" <form class=\"inline\" method=\"POST\" action=\"{2}\">" +
- " <input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{14}\">" +
" <small><input type=\"submit\" value=\"{3}\"></small>" +
" </form>\n" +
" <form class=\"inline\" method=\"POST\" action=\"{4}\">" +
- " <input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{14}\">" +
" <small><input type=\"submit\" value=\"{5}\"></small>" +
" </form>\n" +
" <small>{7}</small> \n" +
private static final String STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION =
" <td class=\"row-left\" bgcolor=\"{13}\" rowspan=\"2\">\n" +
" <form class=\"inline\" method=\"POST\" action=\"{0}\">" +
- " <input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{14}\">" +
" <small><input type=\"submit\" value=\"{1}\"></small>" +
" </form>\n" +
" <small>{3}</small> \n" +
"<tr>\n" +
" <td colspan=\"2\">\n" +
"<form method=\"post\" action=\"{2}\">\n" +
- "<input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{7}\" >" +
"<table cellspacing=\"0\" cellpadding=\"3\">\n" +
"<tr>\n" +
" <td class=\"row-right\">\n" +
" <td colspan=\"2\">\n" +
"<form method=\"post\" action=\"{1}\" " +
"enctype=\"multipart/form-data\">\n" +
- "<input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{4}\" >" +
"<table cellspacing=\"0\" cellpadding=\"3\">\n" +
"<tr>\n" +
" <td class=\"row-right\">\n" +
"<tr>\n" +
" <td colspan=\"2\">\n" +
"<form method=\"post\" action=\"{2}\">\n" +
- "<input type=\"hidden\" name=\"" + NONCE_REQUEST + "\" value=\"{3}\" >" +
"<table cellspacing=\"0\" cellpadding=\"3\">\n" +
"<tr>\n" +
" <td class=\"row-left\">\n" +
- " <input type=\"submit\" value=\"{5}\">\n" +
+ " <input type=\"submit\" value=\"{4}\">\n" +
" </td>\n" +
" <td class=\"row-left\">\n" +
- " <small>{4}</small>\n" +
+ " <small>{3}</small>\n" +
" </td>\n" +
"</tr>\n" +
"</table>\n" +
Session currentSession = (Session)request.getAttribute("currentSession");
HttpSession currentHttpSession = currentSession.getSession();
String currentSessionId = currentSession.getId();
- String submitUrl = ((HttpServletRequest)pageContext.getRequest()).getRequestURL().toString();
+ String submitUrl = response.encodeURL(((HttpServletRequest)
+ pageContext.getRequest()).getRequestURL().toString());
%>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
- <meta http-equiv="pragma" content="no-cache"/><!-- HTTP 1.0 -->
- <meta http-equiv="cache-control" content="no-cache,must-revalidate"/><!-- HTTP 1.1 -->
- <meta http-equiv="expires" content="0"/><!-- 0 is an invalid value and should be treated as 'now' -->
- <meta http-equiv="content-language" content="en"/>
- <meta name="author" content="Cedrik LIME"/>
- <meta name="copyright" content="copyright 2005-2010 the Apache Software Foundation"/>
- <meta name="robots" content="noindex,nofollow,noarchive"/>
- <title>Sessions Administration: details for <%= currentSessionId %></title>
+ <meta http-equiv="pragma" content="no-cache"/><!-- HTTP 1.0 -->
+ <meta http-equiv="cache-control" content="no-cache,must-revalidate"/><!-- HTTP 1.1 -->
+ <meta http-equiv="expires" content="0"/><!-- 0 is an invalid value and should be treated as 'now' -->
+ <meta http-equiv="content-language" content="en"/>
+ <meta name="author" content="Cedrik LIME"/>
+ <meta name="copyright" content="copyright 2005-2010 the Apache Software Foundation"/>
+ <meta name="robots" content="noindex,nofollow,noarchive"/>
+ <title>Sessions Administration: details for <%= currentSessionId %></title>
</head>
<body>
<h1>Details for Session <%= JspHelper.escapeXml(currentSessionId) %></h1>
</tr>
</table>
-<p style="text-align: center;"><button type="button" onclick="window.location.reload()">Refresh</button></p>
+<form method="post" action="<%= submitUrl %>">
+ <div>
+ <input type="hidden" name="path" value="<%= path %>" />
+ <input type="hidden" name="sessionId" value="<%= currentSessionId %>" />
+ <input type="hidden" name="action" value="sessionDetail" />
+ <input type="submit" value="Refresh" />
+ </div>
+</form>
<div class="error"><%= JspHelper.escapeXml(request.getAttribute("error")) %></div>
<div class="message"><%= JspHelper.escapeXml(request.getAttribute("message")) %></div>
<% int nAttributes = 0;
Enumeration attributeNamesEnumeration = currentHttpSession.getAttributeNames();
while (attributeNamesEnumeration.hasMoreElements()) {
- attributeNamesEnumeration.nextElement();
- ++nAttributes;
+ attributeNamesEnumeration.nextElement();
+ ++nAttributes;
}
%>
- <caption style="font-variant: small-caps;"><%= JspHelper.formatNumber(nAttributes) %> attributes</caption>
- <thead>
- <tr>
- <th>Remove Attribute</th>
- <th>Attribute name</th>
- <th>Attribute value</th>
- </tr>
- </thead>
- <%--tfoot>
- <tr>
- <td colspan="3" style="text-align: center;">
- TODO: set Max Inactive Interval on sessions
- </td>
- </tr>
- </tfoot--%>
- <tbody>
+ <caption style="font-variant: small-caps;"><%= JspHelper.formatNumber(nAttributes) %> attributes</caption>
+ <thead>
+ <tr>
+ <th>Remove Attribute</th>
+ <th>Attribute name</th>
+ <th>Attribute value</th>
+ </tr>
+ </thead>
+ <%--tfoot>
+ <tr>
+ <td colspan="3" style="text-align: center;">
+ TODO: set Max Inactive Interval on sessions
+ </td>
+ </tr>
+ </tfoot--%>
+ <tbody>
<% attributeNamesEnumeration = currentHttpSession.getAttributeNames();
while (attributeNamesEnumeration.hasMoreElements()) {
- String attributeName = (String) attributeNamesEnumeration.nextElement();
+ String attributeName = (String) attributeNamesEnumeration.nextElement();
%>
- <tr>
- <td align="center"><form action="<%= submitUrl %>"><div><input type="hidden" name="path" value="<%= path %>" /><input type="hidden" name="action" value="removeSessionAttribute" /><input type="hidden" name="sessionId" value="<%= currentSessionId %>" /><input type="hidden" name="attributeName" value="<%= attributeName %>" /><input type="submit" value="Remove" /></div></form></td>
- <td><%= JspHelper.escapeXml(attributeName) %></td>
- <td><% Object attributeValue = currentHttpSession.getAttribute(attributeName); %><span title="<%= attributeValue == null ? "" : attributeValue.getClass().toString() %>"><%= JspHelper.escapeXml(attributeValue) %></span></td>
- </tr>
+ <tr>
+ <td align="center">
+ <form method="post" action="<%= submitUrl %>">
+ <div>
+ <input type="hidden" name="path" value="<%= path %>" />
+ <input type="hidden" name="action" value="removeSessionAttribute" />
+ <input type="hidden" name="sessionId" value="<%= currentSessionId %>" />
+ <input type="hidden" name="attributeName" value="<%= attributeName %>" />
+ <input type="submit" value="Remove" />
+ </div>
+ </form>
+ </td>
+ <td><%= JspHelper.escapeXml(attributeName) %></td>
+ <td><% Object attributeValue = currentHttpSession.getAttribute(attributeName); %><span title="<%= attributeValue == null ? "" : attributeValue.getClass().toString() %>"><%= JspHelper.escapeXml(attributeValue) %></span></td>
+ </tr>
<% } // end while %>
- </tbody>
+ </tbody>
</table>
-<p style="text-align: center;"><button type="button" onclick="window.close()">Close window</button></p>
+<form method="post" action="<%=submitUrl%>">
+ <p style="text-align: center;">
+ <input type="hidden" name="path" value="<%= path %>" />
+ <input type="submit" value="Return to session list" />
+ </p>
+</form>
<%--div style="display: none;">
<p>
- <a href="http://validator.w3.org/check?uri=referer"><img
- src="http://www.w3.org/Icons/valid-html401"
- alt="Valid HTML 4.01!" height="31" width="88"></a>
- <a href="http://validator.w3.org/check?uri=referer"><img
- src="http://www.w3.org/Icons/valid-xhtml10"
- alt="Valid XHTML 1.0!" height="31" width="88" /></a>
- <a href="http://validator.w3.org/check?uri=referer"><img
- src="http://www.w3.org/Icons/valid-xhtml11"
- alt="Valid XHTML 1.1!" height="31" width="88" /></a>
+ <a href="http://validator.w3.org/check?uri=referer"><img
+ src="http://www.w3.org/Icons/valid-html401"
+ alt="Valid HTML 4.01!" height="31" width="88"></a>
+ <a href="http://validator.w3.org/check?uri=referer"><img
+ src="http://www.w3.org/Icons/valid-xhtml10"
+ alt="Valid XHTML 1.0!" height="31" width="88" /></a>
+ <a href="http://validator.w3.org/check?uri=referer"><img
+ src="http://www.w3.org/Icons/valid-xhtml11"
+ alt="Valid XHTML 1.1!" height="31" width="88" /></a>
</p>
</div--%>