### Eclipse Workspace Patch 1.0 #P tomcat6 Index: java/org/apache/catalina/manager/HTMLManagerServlet.java =================================================================== --- java/org/apache/catalina/manager/HTMLManagerServlet.java (revision 804515) +++ java/org/apache/catalina/manager/HTMLManagerServlet.java (working copy) @@ -112,38 +112,56 @@ response.setContentType("text/html; charset=" + Constants.CHARSET); String message = ""; - // Process the requested command - if (command == null || command.equals("/")) { - } else if (command.equals("/deploy")) { - message = deployInternal(deployConfig, deployPath, deployWar); - } else if (command.equals("/list")) { - } else if (command.equals("/reload")) { - message = reload(path); - } else if (command.equals("/undeploy")) { - message = undeploy(path); - } else if (command.equals("/expire")) { - message = expireSessions(path, request); - } else if (command.equals("/sessions")) { - try { - doSessions(path, request, response); - return; - } catch (Exception e) { - log("HTMLManagerServlet.sessions[" + path + "]", e); - message = sm.getString("managerServlet.exception", - e.toString()); - } - } else if (command.equals("/start")) { - message = start(path); - } else if (command.equals("/stop")) { - message = stop(path); - } else { - message = - sm.getString("managerServlet.unknownCommand", command); + + try { + // Process the requested command + if (command == null || command.equals("/")) { + } else if (command.equals("/deploy")) { + assurePost(request); + message = deployInternal(deployConfig, deployPath, deployWar); + } else if (command.equals("/list")) { + } else if (command.equals("/reload")) { + assurePost(request); + message = reload(path); + } else if (command.equals("/undeploy")) { + assurePost(request); + message = undeploy(path); + } else if (command.equals("/expire")) { + assurePost(request); + message = expireSessions(path, request); + } else if (command.equals("/sessions")) { + try { + doSessions(path, request, response); + return; + } catch (Exception e) { + log("HTMLManagerServlet.sessions[" + path + "]", e); + message = sm.getString("managerServlet.exception", + e.toString()); + } + } else if (command.equals("/start")) { + assurePost(request); + message = start(path); + } else if (command.equals("/stop")) { + assurePost(request); + message = stop(path); + } else { + message = + sm.getString("managerServlet.unknownCommand", command); + } + } catch (IllegalHttpMethodException e) { + response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "Use POST requests for this URL"); + return; } list(request, response, message); } + private void assurePost(HttpServletRequest request) { + if (!request.getMethod().equals("POST")) { + throw new IllegalHttpMethodException(); + } + } + /** * Process a POST request for the specified resource. * @@ -954,6 +972,9 @@ //TODO: complete this to TTL, etc. return comparator; } + + class IllegalHttpMethodException extends RuntimeException { + } // ------------------------------------------------------ Private Constants @@ -1004,12 +1025,16 @@ private static final String STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTION = " \n" + - " \n" + - "  {1} \n" + - "  {3} \n" + - "  {5} \n" + - "  {7} \n" + - " \n" + + "  {1} \n" + + "
\n" + + "   \n" + + "
\n" + + "
\n" + + "   \n" + + "
\n" + + "
\n" + + "   \n" + + "
\n" + " \n" + " \n" + " \n" + @@ -1023,30 +1048,40 @@ private static final String STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION = " \n" + - " \n" + - "  {1} \n" + + "
\n" + + "   \n" + + "
\n" + + " " + "  {3} \n" + "  {5} \n" + - "  {7} \n" + " \n" + + "
\n" + + "   \n" + + "
\n" + " \n" + "\n\n"; private static final String STARTED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION = " \n" + - " \n" + + " " + "  {1} \n" + - "  {3} \n" + - "  {5} \n" + - "  {7} \n" + - " \n" + + " " + + "
\n" + + "   \n" + + "
\n" + + "
\n" + + "   \n" + + "
\n" + + "  {7} \n" + " \n" + "\n\n"; private static final String STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION = " \n" + + "
\n" + + "   \n" + + "
\n" + " \n" + - "  {1} \n" + "  {3} \n" + "  {5} \n" + "  {7} \n" + @@ -1066,7 +1101,7 @@ "\n" + "\n" + " \n" + - "
\n" + + "\n" + "\n" + "\n" + "
\n" +