You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2005/02/19 04:04:43 UTC

DO NOT REPLY [Bug 32795] - If RequestDumperValve is enabled, the request parameter value parsed by default character encoding is always returned.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32795>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32795


lizongbo@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From lizongbo@gmail.com  2005-02-19 04:04 -------
you can use a class like follow,then set fllow coment in your server.xml
(you)
First,the xml config:
----------------------------
<Valve className="org.apache.catalina.valves.CharSetValve" encoding="GBK"/>
<!--this is must before fllow-->
 <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
----------------------------
you should place this classfile in
%TOMCATHOME%\server\classes\org\apache\catalina\valves
eg: "D:\jakarta-tomcat-5.5.7
\server\classes\org\apache\catalina\valves\CharSetValve.class"



the java code :

-----------------

package org.apache.catalina.valves;

import java.io.*;
import javax.servlet.*;

import org.apache.catalina.*;
import org.apache.catalina.connector.*;
import org.apache.catalina.util.*;

/**
 * <p>Title: CharSetValve </p>
 * <p>Description: a CharSet Filter for Tomcat Application</p>
 * <p>Copyright: Apache License Version 2.0  </p>
 * <p>Company: lizongbo</p>
 * @author lizongbo @ gmail.com
 * @version 1.0
 */
public class CharSetValve
    extends ValveBase implements Lifecycle {
  public CharSetValve() {
    super();
  }

  protected LifecycleSupport lifecycle = new LifecycleSupport(this);

  private StringManager sm =
      StringManager.getManager(Constants.Package);

  private boolean started = false;
  private String encoding = System.setProperty("file.encoding", "GBK");

  public String getEncoding() {
    return encoding;
  }

  public void setEncoding(String encoding) {
    this.encoding = encoding;
  }

  public void invoke(Request request, Response response) throws IOException,
      ServletException {
    request.getRequest().setCharacterEncoding(getEncoding());
    getNext().invoke(request, response);

  }

  public void addLifecycleListener(LifecycleListener listener) {
    lifecycle.addLifecycleListener(listener);
  }

  public LifecycleListener[] findLifecycleListeners() {
    return lifecycle.findLifecycleListeners();

  }

  public void removeLifecycleListener(LifecycleListener listener) {

    lifecycle.removeLifecycleListener(listener);

  }

  public void start() throws LifecycleException {

    if (started) {
      throw new LifecycleException
          (sm.getString("accessLogValve.alreadyStarted"));
    }

  }

  public void stop() throws LifecycleException {
    if (!started) {
      throw new LifecycleException
          (sm.getString("accessLogValve.notStarted"));
    }
    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

  }
}

-------------------------------


also you can see:

http://issues.apache.org/bugzilla/show_bug.cgi?id=33632

maybe useful:)

enjoy it!!!  ^_^ 



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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