You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by TANAKA Yoshihiro <to...@ytp.ne.jp> on 2003/08/28 18:39:11 UTC

[PATCH] Tomcat5 StatusManagerServlet

I couldn't get correct Japanese messages on "Server Status"
in the HTML manager screen because the StatusManagerServlet of TC5
has a problem about i18n.

I made a patch as follows, and hope that you will include it
on next release.

Thanx for developing Tomcat!


Index: StatusManagerServlet.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-catalina/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/StatusManagerServlet.java,v
retrieving revision 1.10
diff -u -r1.10 StatusManagerServlet.java
--- StatusManagerServlet.java	17 Aug 2003 14:50:24 -0000	1.10
+++ StatusManagerServlet.java	23 Aug 2003 15:38:09 -0000
@@ -70,6 +70,7 @@
 import java.text.MessageFormat;
 import java.util.Enumeration;
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.Set;
 import java.util.Vector;
 
@@ -90,6 +91,10 @@
 
 import org.apache.tomcat.util.compat.JdkCompat;
 
+import org.apache.catalina.ContainerServlet;
+import org.apache.catalina.Context;
+import org.apache.catalina.Deployer;
+import org.apache.catalina.Wrapper;
 import org.apache.catalina.util.ServerInfo;
 import org.apache.catalina.util.StringManager;
 
@@ -101,7 +106,7 @@
  */
 
 public class StatusManagerServlet
-    extends HttpServlet implements NotificationListener {
+    extends HttpServlet implements NotificationListener, ContainerServlet {
 
 
     // ----------------------------------------------------- Instance Variables
@@ -150,8 +155,57 @@
         StringManager.getManager(Constants.Package);
 
 
+    /**
+     * The Context container associated with our web application.
+     */
+    protected Context context = null;
+
+
+    /**
+     * The Wrapper container associated with this servlet.
+     */
+    protected Wrapper wrapper = null;
+
+
+    /**
+     * The Deployer container that contains our own web application's Context,
+     * along with the associated Contexts for web applications that we
+     * are managing.
+     */
+    protected Deployer deployer = null;
+
+
     // --------------------------------------------------------- Public Methods
 
+    // getWrapper() & setWrapper() are added to get Context. (ytp)
+    /**
+     * Return the Wrapper with which we are associated.
+     */
+    public Wrapper getWrapper() {
+
+        return (this.wrapper);
+
+    }
+
+
+    /**
+     * Set the Wrapper with which we are associated.
+     *
+     * @param wrapper The new wrapper
+     */
+    public void setWrapper(Wrapper wrapper) {
+
+        this.wrapper = wrapper;
+        if (wrapper == null) {
+            context = null;
+            deployer = null;
+        } else {
+            context = (Context) wrapper.getParent();
+            deployer = (Deployer) context.getParent();
+        }
+
+    }
+
 
     /**
      * Initialize this servlet.
@@ -247,7 +301,10 @@
                       HttpServletResponse response)
         throws IOException, ServletException {
 
-        response.setContentType("text/html");
+        Locale locale = Locale.getDefault();
+        String charset = context.getCharsetMapper().getCharset(locale);
+        response.setLocale(locale);
+        response.setContentType("text/html; charset=" + charset);
 
         PrintWriter writer = response.getWriter();
 

----------------------------------
       TANAKA Yoshihiro(ytp)     /   http://www.ytp.ne.jp/
                                 -------------------------------


Re: [PATCH] Tomcat5 StatusManagerServlet

Posted by Kazuhiro Kazama <ka...@ingrid.org>.
Hi, 

I requested Remy to update Japanese messages and they are done. Thank
you, Remy!

But the following patch isn't applied to StatusManagerServlet.java yet
and a part of messages aren't displayed correctly. Would you include
this change?

From: TANAKA Yoshihiro <to...@ytp.ne.jp>
Subject: [PATCH] Tomcat5 StatusManagerServlet
Date: Fri, 29 Aug 2003 01:39:11 +0900
Message-ID: <20...@ytp.ne.jp>
> I couldn't get correct Japanese messages on "Server Status"
> in the HTML manager screen because the StatusManagerServlet of TC5
> has a problem about i18n.

Kazuhiro Kazama (kazama@ingrid.org)         NTT Network Innovation Laboratories