You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Takayuki Fujimoto <t-...@beingcorp.co.jp> on 2003/04/09 07:57:21 UTC

SetCharacterEncodingFilter Not Working!

I am working with struts and would like to use the filter for encoding.

Refering on the informaiton at http://www.anassina.com/struts/i18n/i18n.html,
I tried to use SetCharacterEncodingFilter.class
but it is not working with me.
Please help.

[directory structure]
$TOMCAT_HOME/webapps/gourmet/WEB-INF/web.xml
				    /classes/filters/SetCharacterEncodingFilter.class


I have placed SetCharacterEncodingFilter.class under WEB-INF/classes/filters 
and My entire WEB-INF/web.xml looks like this.


web.xml  start**********************************************************************
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
    <!-- Example filter to set character encoding on each request -->
    <filter>
        <filter-name>Set Character Encoding</filter-name>
        <filter-class>filters.SetCharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>EUC_JP</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>Set Character Encoding</filter-name>
        <servlet-name>action</servlet-name>
    </filter-mapping>

  <!-- Standard Action Servlet Configuration (with debugging) -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>


  <!-- Standard Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>


  <!-- The Usual Welcome File List -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>


  <!-- Struts Tag Library Descriptors -->
  <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-nested</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-tiles</taglib-uri>
    <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
  </taglib>
</web-app>
web.xml  end**********************************************************************


After restarting TOMCAT, my application does not even start with error code 404.

apache_log.2003-04-09.txt looks like this.

2003-04-09 12:35:25 [org.apache.catalina.connector.warp.WarpConnector] Error accepting requests
java.net.SocketException: Socket closed
        at java.net.PlainSocketImpl.socketAccept(Native Method)
        at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
        at java.net.ServerSocket.implAccept(ServerSocket.java:439)
        at java.net.ServerSocket.accept(ServerSocket.java:410)
        at org.apache.catalina.connector.warp.WarpConnector.run(WarpConnector.java:590)
        at java.lang.Thread.run(Thread.java:536)

I have tried placing the lines between <filter> and </filter-mapping> 
at various parts in web.xml,
it keeps giving me the same error.


If I remove the lines between <filter> and </filter-mapping> from web.xml ,
the application works fine.


[environment]
jakarta-struts-1.1-b3
jakarta-tomcat-4.0.6
Red Hat Linux release 7.1 (Seawolf)
apache_1.3.26
mod_jk-1.3-noeapi.so


Thank you for reading my long email.
Please give me any helping advice if you have time.

Sincerely,


*--------------------------------*
Tak Fujimoto
Being Co, Ltd.  
[ALLESNET]  Network Division
web   : http://www.alles.or.jp/
email : fujimoto@alles.ad.jp
tel : 03-3226-8421
fax : 03-3226-8425
*--------------------------------*


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


Re: SetCharacterEncodingFilter Not Working!

Posted by Takayuki Fujimoto <t-...@beingcorp.co.jp>.
Thank you for your quick response !
The application started to work again.


> The web.xml doctype needs to version 2.3 to support filters, change
> 
> <!DOCTYPE web-app
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
>     "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
> 
> to
> 
> <!DOCTYPE web-app
>       PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>      "http://java.sun.com/dtd/web-app_2_3.dtd">
> 
> 
> -- 
> Jason Lea


*--------------------------------*
Tak Fujimoto
Being Co, Ltd.  
[ALLESNET]  Network Division
web   : http://www.alles.or.jp/
email : fujimoto@alles.ad.jp
tel : 03-3226-8421
fax : 03-3226-8425
*--------------------------------*


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


Re: SetCharacterEncodingFilter Not Working!

Posted by Jason Lea <ja...@kumachan.net.nz>.
Takayuki Fujimoto wrote:
> I am working with struts and would like to use the filter for encoding.
> 
> Refering on the informaiton at http://www.anassina.com/struts/i18n/i18n.html,
> I tried to use SetCharacterEncodingFilter.class
> but it is not working with me.
> Please help.
> 
> [directory structure]
> $TOMCAT_HOME/webapps/gourmet/WEB-INF/web.xml
> 				    /classes/filters/SetCharacterEncodingFilter.class
> 
> 
> I have placed SetCharacterEncodingFilter.class under WEB-INF/classes/filters 
> and My entire WEB-INF/web.xml looks like this.
> 
> 
> web.xml  start**********************************************************************
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE web-app
>   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
>   "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

Hi Takayuki,

The web.xml doctype needs to version 2.3 to support filters, change

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

to

<!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
     "http://java.sun.com/dtd/web-app_2_3.dtd">


-- 
Jason Lea


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