tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1023366 - in /tomcat/trunk/java/org/apache/catalina/manager/host: HTMLHostManagerServlet.java HostManagerServlet.java
Date Sat, 16 Oct 2010 19:54:45 GMT
Author: markt
Date: Sat Oct 16 19:54:44 2010
New Revision: 1023366

URL: http://svn.apache.org/viewvc?rev=1023366&view=rev
Log:
Messages displayed to the user in the Host Manager (text and HTML) should be based on the
Locale of the user, not the server

Modified:
    tomcat/trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java
    tomcat/trunk/java/org/apache/catalina/manager/host/HostManagerServlet.java

Modified: tomcat/trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java?rev=1023366&r1=1023365&r2=1023366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java Sat Oct
16 19:54:44 2010
@@ -35,6 +35,7 @@ import org.apache.catalina.Container;
 import org.apache.catalina.Host;
 import org.apache.catalina.util.RequestUtil;
 import org.apache.catalina.util.ServerInfo;
+import org.apache.tomcat.util.res.StringManager;
 
 /**
 * Servlet that enables remote management of the virtual hosts deployed
@@ -79,6 +80,8 @@ public final class HTMLHostManagerServle
                       HttpServletResponse response)
         throws IOException, ServletException {
 
+        StringManager smClient = getStringManager(request);
+
         // Identify the request parameters that we need
         String command = request.getPathInfo();
 
@@ -93,14 +96,14 @@ public final class HTMLHostManagerServle
             // Nothing to do - always generate list
         } else if (command.equals("/add") || command.equals("/remove") ||
                 command.equals("/start") || command.equals("/stop")) {
-            message =
-                sm.getString("hostManagerServlet.postCommand", command);
+            message = smClient.getString(
+                    "hostManagerServlet.postCommand", command);
         } else {
-            message =
-                sm.getString("hostManagerServlet.unknownCommand", command);
+            message = smClient.getString(
+                    "hostManagerServlet.unknownCommand", command);
         }
 
-        list(request, response, message);
+        list(request, response, message, smClient);
     }
 
     
@@ -116,7 +119,9 @@ public final class HTMLHostManagerServle
     @Override
     public void doPost(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {
-        
+
+        StringManager smClient = getStringManager(request);
+
         // Identify the request parameters that we need
         String command = request.getPathInfo();
 
@@ -131,19 +136,19 @@ public final class HTMLHostManagerServle
         if (command == null) {
             // No command == list
         } else if (command.equals("/add")) {
-            message = add(request, name);
+            message = add(request, name, smClient);
         } else if (command.equals("/remove")) {
-            message = remove(name);
+            message = remove(name, smClient);
         } else if (command.equals("/start")) {
-            message = start(name);
+            message = start(name, smClient);
         } else if (command.equals("/stop")) {
-            message = stop(name);
+            message = stop(name, smClient);
         } else {
             //Try GET
             doGet(request, response);
         }
 
-        list(request, response, message);
+        list(request, response, message, smClient);
     }
 
 
@@ -152,12 +157,13 @@ public final class HTMLHostManagerServle
      *
      * @param name host name
      */
-    protected String add(HttpServletRequest request,String name) {
+    protected String add(HttpServletRequest request,String name,
+            StringManager smClient) {
 
         StringWriter stringWriter = new StringWriter();
         PrintWriter printWriter = new PrintWriter(stringWriter);
 
-        super.add(request,printWriter,name,true);
+        super.add(request,printWriter,name,true, smClient);
 
         return stringWriter.toString();
     }
@@ -168,12 +174,12 @@ public final class HTMLHostManagerServle
      *
      * @param name host name
      */
-    protected String remove(String name) {
+    protected String remove(String name, StringManager smClient) {
 
         StringWriter stringWriter = new StringWriter();
         PrintWriter printWriter = new PrintWriter(stringWriter);
 
-        super.remove(printWriter, name);
+        super.remove(printWriter, name, smClient);
 
         return stringWriter.toString();
     }
@@ -184,12 +190,12 @@ public final class HTMLHostManagerServle
      *
      * @param name Host name
      */
-    protected String start(String name) {
+    protected String start(String name, StringManager smClient) {
 
         StringWriter stringWriter = new StringWriter();
         PrintWriter printWriter = new PrintWriter(stringWriter);
 
-        super.start(printWriter, name);
+        super.start(printWriter, name, smClient);
 
         return stringWriter.toString();
     }
@@ -200,12 +206,12 @@ public final class HTMLHostManagerServle
      *
      * @param name Host name
      */
-    protected String stop(String name) {
+    protected String stop(String name, StringManager smClient) {
 
         StringWriter stringWriter = new StringWriter();
         PrintWriter printWriter = new PrintWriter(stringWriter);
 
-        super.stop(printWriter, name);
+        super.stop(printWriter, name, smClient);
 
         return stringWriter.toString();
     }
@@ -221,7 +227,8 @@ public final class HTMLHostManagerServle
      */
     public void list(HttpServletRequest request,
                      HttpServletResponse response,
-                     String message) throws IOException {
+                     String message,
+                     StringManager smClient) throws IOException {
 
         if (debug >= 1) {
             log(sm.getString("hostManagerServlet.list", engine.getName()));
@@ -235,13 +242,13 @@ public final class HTMLHostManagerServle
         // Body Header Section
         Object[] args = new Object[2];
         args[0] = request.getContextPath();
-        args[1] = sm.getString("htmlHostManagerServlet.title");
+        args[1] = smClient.getString("htmlHostManagerServlet.title");
         writer.print(MessageFormat.format
                      (Constants.BODY_HEADER_SECTION, args));
 
         // Message Section
         args = new Object[3];
-        args[0] = sm.getString("htmlHostManagerServlet.messageLabel");
+        args[0] = smClient.getString("htmlHostManagerServlet.messageLabel");
         if (message == null || message.length() == 0) {
             args[1] = "OK";
         } else {
@@ -251,26 +258,26 @@ public final class HTMLHostManagerServle
 
         // Manager Section
         args = new Object[9];
-        args[0] = sm.getString("htmlHostManagerServlet.manager");
+        args[0] = smClient.getString("htmlHostManagerServlet.manager");
         args[1] = response.encodeURL(request.getContextPath() + "/html/list");
-        args[2] = sm.getString("htmlHostManagerServlet.list");
+        args[2] = smClient.getString("htmlHostManagerServlet.list");
         args[3] = response.encodeURL
             (request.getContextPath() + "/" +
-             sm.getString("htmlHostManagerServlet.helpHtmlManagerFile"));
-        args[4] = sm.getString("htmlHostManagerServlet.helpHtmlManager");
+             smClient.getString("htmlHostManagerServlet.helpHtmlManagerFile"));
+        args[4] = smClient.getString("htmlHostManagerServlet.helpHtmlManager");
         args[5] = response.encodeURL
             (request.getContextPath() + "/" +
-             sm.getString("htmlHostManagerServlet.helpManagerFile"));
-        args[6] = sm.getString("htmlHostManagerServlet.helpManager");
+             smClient.getString("htmlHostManagerServlet.helpManagerFile"));
+        args[6] = smClient.getString("htmlHostManagerServlet.helpManager");
         args[7] = response.encodeURL("/manager/status");
-        args[8] = sm.getString("statusServlet.title");
+        args[8] = smClient.getString("statusServlet.title");
         writer.print(MessageFormat.format(Constants.MANAGER_SECTION, args));
 
          // Hosts Header Section
         args = new Object[3];
-        args[0] = sm.getString("htmlHostManagerServlet.hostName");
-        args[1] = sm.getString("htmlHostManagerServlet.hostAliases");
-        args[2] = sm.getString("htmlHostManagerServlet.hostTasks");
+        args[0] = smClient.getString("htmlHostManagerServlet.hostName");
+        args[1] = smClient.getString("htmlHostManagerServlet.hostAliases");
+        args[2] = smClient.getString("htmlHostManagerServlet.hostTasks");
         writer.print(MessageFormat.format(HOSTS_HEADER_SECTION, args));
 
         // Hosts Row Section
@@ -288,9 +295,12 @@ public final class HTMLHostManagerServle
             sortedHostNamesMap.put(displayPath, hostNames[i]);
         }
 
-        String hostsStart = sm.getString("htmlHostManagerServlet.hostsStart");
-        String hostsStop = sm.getString("htmlHostManagerServlet.hostsStop");
-        String hostsRemove = sm.getString("htmlHostManagerServlet.hostsRemove");
+        String hostsStart =
+            smClient.getString("htmlHostManagerServlet.hostsStart");
+        String hostsStop =
+            smClient.getString("htmlHostManagerServlet.hostsStop");
+        String hostsRemove =
+            smClient.getString("htmlHostManagerServlet.hostsRemove");
 
         Iterator<Map.Entry<String,String>> iterator =
             sortedHostNamesMap.entrySet().iterator();
@@ -352,50 +362,51 @@ public final class HTMLHostManagerServle
 
         // Add Section
         args = new Object[6];
-        args[0] = sm.getString("htmlHostManagerServlet.addTitle");
-        args[1] = sm.getString("htmlHostManagerServlet.addHost");
+        args[0] = smClient.getString("htmlHostManagerServlet.addTitle");
+        args[1] = smClient.getString("htmlHostManagerServlet.addHost");
         args[2] = response.encodeURL(request.getContextPath() + "/html/add");
-        args[3] = sm.getString("htmlHostManagerServlet.addName");
-        args[4] = sm.getString("htmlHostManagerServlet.addAliases");
-        args[5] = sm.getString("htmlHostManagerServlet.addAppBase");
+        args[3] = smClient.getString("htmlHostManagerServlet.addName");
+        args[4] = smClient.getString("htmlHostManagerServlet.addAliases");
+        args[5] = smClient.getString("htmlHostManagerServlet.addAppBase");
         writer.print(MessageFormat.format(ADD_SECTION_START, args));
  
         args = new Object[3];
-        args[0] = sm.getString("htmlHostManagerServlet.addAutoDeploy");
+        args[0] = smClient.getString("htmlHostManagerServlet.addAutoDeploy");
         args[1] = "autoDeploy";
         args[2] = "checked";
         writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
-        args[0] = sm.getString("htmlHostManagerServlet.addDeployOnStartup");
+        args[0] = smClient.getString(
+                "htmlHostManagerServlet.addDeployOnStartup");
         args[1] = "deployOnStartup";
         args[2] = "checked";
         writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
-        args[0] = sm.getString("htmlHostManagerServlet.addDeployXML");
+        args[0] = smClient.getString("htmlHostManagerServlet.addDeployXML");
         args[1] = "deployXML";
         args[2] = "checked";
         writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
-        args[0] = sm.getString("htmlHostManagerServlet.addUnpackWARs");
+        args[0] = smClient.getString("htmlHostManagerServlet.addUnpackWARs");
         args[1] = "unpackWARs";
         args[2] = "checked";
         writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
 
-        args[0] = sm.getString("htmlHostManagerServlet.addManager");
+        args[0] = smClient.getString("htmlHostManagerServlet.addManager");
         args[1] = "manager";
         args[2] = "checked";
         writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
         
         args = new Object[1];
-        args[0] = sm.getString("htmlHostManagerServlet.addButton");
+        args[0] = smClient.getString("htmlHostManagerServlet.addButton");
         writer.print(MessageFormat.format(ADD_SECTION_END, args));
 
         // Server Header Section
         args = new Object[7];
-        args[0] = sm.getString("htmlHostManagerServlet.serverTitle");
-        args[1] = sm.getString("htmlHostManagerServlet.serverVersion");
-        args[2] = sm.getString("htmlHostManagerServlet.serverJVMVersion");
-        args[3] = sm.getString("htmlHostManagerServlet.serverJVMVendor");
-        args[4] = sm.getString("htmlHostManagerServlet.serverOSName");
-        args[5] = sm.getString("htmlHostManagerServlet.serverOSVersion");
-        args[6] = sm.getString("htmlHostManagerServlet.serverOSArch");
+        args[0] = smClient.getString("htmlHostManagerServlet.serverTitle");
+        args[1] = smClient.getString("htmlHostManagerServlet.serverVersion");
+        args[2] = smClient.getString("htmlHostManagerServlet.serverJVMVersion");
+        args[3] = smClient.getString("htmlHostManagerServlet.serverJVMVendor");
+        args[4] = smClient.getString("htmlHostManagerServlet.serverOSName");
+        args[5] = smClient.getString("htmlHostManagerServlet.serverOSVersion");
+        args[6] = smClient.getString("htmlHostManagerServlet.serverOSArch");
         writer.print(MessageFormat.format
                      (Constants.SERVER_HEADER_SECTION, args));
 

Modified: tomcat/trunk/java/org/apache/catalina/manager/host/HostManagerServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/manager/host/HostManagerServlet.java?rev=1023366&r1=1023365&r2=1023366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/manager/host/HostManagerServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/manager/host/HostManagerServlet.java Sat Oct 16
19:54:44 2010
@@ -25,6 +25,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.Locale;
 import java.util.StringTokenizer;
 
 import javax.management.MBeanServer;
@@ -210,6 +212,8 @@ public class HostManagerServlet
                       HttpServletResponse response)
         throws IOException, ServletException {
 
+        StringManager smClient = getStringManager(request);
+
         // Identify the request parameters that we need
         String command = request.getPathInfo();
         if (command == null)
@@ -224,15 +228,15 @@ public class HostManagerServlet
         if (command == null) {
             writer.println(sm.getString("hostManagerServlet.noCommand"));
         } else if (command.equals("/add")) {
-            add(request, writer, name, false);
+            add(request, writer, name, false, smClient);
         } else if (command.equals("/remove")) {
-            remove(writer, name);
+            remove(writer, name, smClient);
         } else if (command.equals("/list")) {
-            list(writer);
+            list(writer, smClient);
         } else if (command.equals("/start")) {
-            start(writer, name);
+            start(writer, name, smClient);
         } else if (command.equals("/stop")) {
-            stop(writer, name);
+            stop(writer, name, smClient);
         } else {
             writer.println(sm.getString("hostManagerServlet.unknownCommand",
                                         command));
@@ -253,7 +257,8 @@ public class HostManagerServlet
      * @param name The host name
      * @param htmlMode Flag value
      */
-    protected void add(HttpServletRequest request, PrintWriter writer, String name, boolean
htmlMode ) {
+    protected void add(HttpServletRequest request, PrintWriter writer,
+            String name, boolean htmlMode, StringManager smClient) {
         String aliases = request.getParameter("aliases");
         String appBase = request.getParameter("appBase");
         boolean manager = booleanParameter(request, "manager", false, htmlMode);
@@ -265,7 +270,8 @@ public class HostManagerServlet
             autoDeploy,
             deployOnStartup,
             deployXML,                                       
-            unpackWARs);
+            unpackWARs,
+            smClient);
     }
 
 
@@ -340,21 +346,23 @@ public class HostManagerServlet
          boolean autoDeploy,
          boolean deployOnStartup,
          boolean deployXML,                                       
-         boolean unpackWARs) {
+         boolean unpackWARs,
+         StringManager smClient) {
         if (debug >= 1) {
             log(sm.getString("hostManagerServlet.add", name));
         }
 
         // Validate the requested host name
         if ((name == null) || name.length() == 0) {
-            writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.invalidHostName", name));
             return;
         }
 
         // Check if host already exists
         if (engine.findChild(name) != null) {
-            writer.println
-                (sm.getString("hostManagerServlet.alreadyHost", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.alreadyHost", name));
             return;
         }
 
@@ -375,7 +383,7 @@ public class HostManagerServlet
         }
         if (!appBaseFile.exists()) {
             if (!appBaseFile.mkdirs()) {
-                writer.println(sm.getString(
+                writer.println(smClient.getString(
                         "hostManagerServlet.appBaseCreateFail",
                         appBaseFile.toString(), name));
                 return;
@@ -388,7 +396,7 @@ public class HostManagerServlet
         // Copy manager.xml if requested
         if (manager) {
             if (configBaseFile == null) {
-                writer.println(sm.getString(
+                writer.println(smClient.getString(
                         "hostManagerServlet.configBaseCreateFail", name));
                 return;
             }
@@ -406,8 +414,8 @@ public class HostManagerServlet
                     os.write(buffer, 0, len);
                 }
             } catch (IOException e) {
-                writer.println
-                    (sm.getString("hostManagerServlet.managerXml"));
+                writer.println(smClient.getString(
+                        "hostManagerServlet.managerXml"));
                 return;
             } finally {
                 if (is != null) {
@@ -449,17 +457,18 @@ public class HostManagerServlet
         try {
             engine.addChild(host);
         } catch (Exception e) {
-            writer.println(sm.getString("hostManagerServlet.exception",
-                                        e.toString()));
+            writer.println(smClient.getString("hostManagerServlet.exception",
+                    e.toString()));
             return;
         }
         
         host = (StandardHost) engine.findChild(name);
         if (host != null) {
-            writer.println(sm.getString("hostManagerServlet.add", name));
+            writer.println(smClient.getString("hostManagerServlet.add", name));
         } else {
             // Something failed
-            writer.println(sm.getString("hostManagerServlet.addFailed", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.addFailed", name));
         }
         
     }
@@ -471,7 +480,8 @@ public class HostManagerServlet
      * @param writer Writer to render results to
      * @param name host name
      */
-    protected synchronized void remove(PrintWriter writer, String name) {
+    protected synchronized void remove(PrintWriter writer, String name,
+            StringManager smClient) {
 
         if (debug >= 1) {
             log(sm.getString("hostManagerServlet.remove", name));
@@ -479,21 +489,22 @@ public class HostManagerServlet
 
         // Validate the requested host name
         if ((name == null) || name.length() == 0) {
-            writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.invalidHostName", name));
             return;
         }
 
         // Check if host exists
         if (engine.findChild(name) == null) {
-            writer.println
-                (sm.getString("hostManagerServlet.noHost", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.noHost", name));
             return;
         }
 
         // Prevent removing our own host
         if (engine.findChild(name) == installedHost) {
-            writer.println
-                (sm.getString("hostManagerServlet.cannotRemoveOwnHost", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.cannotRemoveOwnHost", name));
             return;
         }
 
@@ -504,17 +515,19 @@ public class HostManagerServlet
             engine.removeChild(child);
             if ( child instanceof ContainerBase ) ((ContainerBase)child).destroy();
         } catch (Exception e) {
-            writer.println(sm.getString("hostManagerServlet.exception",
-                                        e.toString()));
+            writer.println(smClient.getString("hostManagerServlet.exception",
+                    e.toString()));
             return;
         }
         
         Host host = (StandardHost) engine.findChild(name);
         if (host == null) {
-            writer.println(sm.getString("hostManagerServlet.remove", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.remove", name));
         } else {
             // Something failed
-            writer.println(sm.getString("hostManagerServlet.removeFailed", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.removeFailed", name));
         }
         
     }
@@ -525,14 +538,14 @@ public class HostManagerServlet
      *
      * @param writer Writer to render to
      */
-    protected void list(PrintWriter writer) {
+    protected void list(PrintWriter writer, StringManager smClient) {
 
         if (debug >= 1) {
             log(sm.getString("hostManagerServlet.list", engine.getName()));
         }
 
-        writer.println(sm.getString("hostManagerServlet.listed",
-                                    engine.getName()));
+        writer.println(smClient.getString("hostManagerServlet.listed",
+                engine.getName()));
         Container[] hosts = engine.findChildren();
         for (int i = 0; i < hosts.length; i++) {
             Host host = (Host) hosts[i];
@@ -545,7 +558,7 @@ public class HostManagerServlet
                     buf.append(',').append(aliases[j]);
                 }
             }
-            writer.println(sm.getString("hostManagerServlet.listitem",
+            writer.println(smClient.getString("hostManagerServlet.listitem",
                                         name, buf.toString()));
         }
     }
@@ -557,7 +570,8 @@ public class HostManagerServlet
      * @param writer Writer to render to
      * @param name Host name
      */
-    protected void start(PrintWriter writer, String name) {
+    protected void start(PrintWriter writer, String name,
+            StringManager smClient) {
 
         if (debug >= 1) {
             log(sm.getString("hostManagerServlet.start", name));
@@ -565,7 +579,8 @@ public class HostManagerServlet
 
         // Validate the requested host name
         if ((name == null) || name.length() == 0) {
-            writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.invalidHostName", name));
             return;
         }
 
@@ -573,37 +588,37 @@ public class HostManagerServlet
         
         // Check if host exists
         if (host == null) {
-            writer.println
-                (sm.getString("hostManagerServlet.noHost", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.noHost", name));
             return;
         }
 
         // Prevent starting our own host
         if (host == installedHost) {
-            writer.println
-                (sm.getString("hostManagerServlet.cannotStartOwnHost", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.cannotStartOwnHost", name));
             return;
         }
 
         // Don't start host of already started
         if (host.getState().isAvailable()) {
-            writer.println
-                (sm.getString("hostManagerServlet.alreadyStarted", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.alreadyStarted", name));
             return;
         }
 
         // Start host
         try {
             host.start();
-            writer.println
-                (sm.getString("hostManagerServlet.started", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.started", name));
         } catch (Exception e) {
             getServletContext().log
                 (sm.getString("hostManagerServlet.startFailed", name), e);
-            writer.println
-                (sm.getString("hostManagerServlet.startFailed", name));
-            writer.println(sm.getString("hostManagerServlet.exception",
-                                        e.toString()));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.startFailed", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.exception", e.toString()));
             return;
         }
         
@@ -616,7 +631,8 @@ public class HostManagerServlet
      * @param writer Writer to render to
      * @param name Host name
      */
-    protected void stop(PrintWriter writer, String name) {
+    protected void stop(PrintWriter writer, String name,
+            StringManager smClient) {
 
         if (debug >= 1) {
             log(sm.getString("hostManagerServlet.stop", name));
@@ -624,7 +640,8 @@ public class HostManagerServlet
 
         // Validate the requested host name
         if ((name == null) || name.length() == 0) {
-            writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.invalidHostName", name));
             return;
         }
 
@@ -632,37 +649,37 @@ public class HostManagerServlet
 
         // Check if host exists
         if (host == null) {
-            writer.println
-                (sm.getString("hostManagerServlet.noHost", name));
+            writer.println(smClient.getString("hostManagerServlet.noHost",
+                    name));
             return;
         }
 
         // Prevent starting our own host
         if (host == installedHost) {
-            writer.println
-                (sm.getString("hostManagerServlet.cannotStopOwnHost", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.cannotStopOwnHost", name));
             return;
         }
 
         // Don't stop host of already stopped
         if (!host.getState().isAvailable()) {
-            writer.println
-                (sm.getString("hostManagerServlet.alreadyStopped", name));
+            writer.println(smClient.getString(
+                    "hostManagerServlet.alreadyStopped", name));
             return;
         }
 
         // Stop host
         try {
             host.stop();
-            writer.println
-                (sm.getString("hostManagerServlet.stopped", name));
+            writer.println(smClient.getString("hostManagerServlet.stopped",
+                    name));
         } catch (Exception e) {
-            getServletContext().log
-                (sm.getString("hostManagerServlet.stopFailed", name), e);
-            writer.println
-                (sm.getString("hostManagerServlet.stopFailed", name));
-            writer.println(sm.getString("hostManagerServlet.exception",
-                                        e.toString()));
+            getServletContext().log(sm.getString(
+                    "hostManagerServlet.stopFailed", name), e);
+            writer.println(smClient.getString("hostManagerServlet.stopFailed",
+                    name));
+            writer.println(smClient.getString("hostManagerServlet.exception",
+                    e.toString()));
             return;
         }
         
@@ -696,4 +713,17 @@ public class HostManagerServlet
     }
 
 
+    protected StringManager getStringManager(HttpServletRequest req) {
+        Enumeration<Locale> requestedLocales = req.getLocales();
+        while (requestedLocales.hasMoreElements()) {
+            Locale locale = requestedLocales.nextElement();
+            StringManager result = StringManager.getManager(Constants.Package,
+                    locale);
+            if (result.getLocale().equals(locale)) {
+                return result;
+            }
+        }
+        // Return the default
+        return sm;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message