If your doing Struts you gotta have a character encoding filter servlet.
Try googling it.
- vineet
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/**
* Example filter that unconditionally sets the character encoding to be
used
* in parsing the incoming request to a value specified by the
* <strong>encoding</string> filter initialization parameter in the web app
* deployment descriptor (</code>/WEB-INF/web.xml</code>). This filter
could
* easily be extended to be more intelligent about what character encoding
to
* set, based on characteristics of the incoming request (such as the values
* of the <code>Accept-Language</code> and <code>User-Agent</code> headers,
* or a value stashed in the current user's session).
*
* @author Craig McClanahan
* @version $Revision: 1.1 $ $Date: 2001/07/24 00:26:55 $
*/
public class SetCharacterEncodingFilter implements Filter {
// ----------------------------------------------------- Instance
Variables
/**
* The default character encoding to set for requests that pass through
* this filter.
*/
protected String encoding = null;
/**
* The filter configuration object we are associated with. If this
value
* is null, this filter instance is not currently configured.
*/
protected FilterConfig filterConfig = null;
// --------------------------------------------------------- Public
Methods
/**
* Take this filter out of service.
*/
public void destroy() {
this.encoding = null;
this.filterConfig = null;
}
/**
* Select and set (if specified) the character encoding to be used to
* interpret request parameters for this request.
*
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
// Select and set (if needed) the character encoding to be used
String encoding = selectEncoding(request);
if (encoding != null)
request.setCharacterEncoding(encoding);
// Pass control on to the next filter
chain.doFilter(request, response);
}
/**
* Place this filter into service.
*
* @param filterConfig The filter configuration object
*/
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
}
// ------------------------------------------------------ Protected
Methods
/**
* Select an appropriate character encoding to be used, based on the
* characteristics of the current request and/or filter initialization
* parameters. If no character encoding should be set, return
* <code>null</code>.
* <p>
* The default implementation unconditionally returns the value
configured
* by the <strong>encoding</strong> initialization parameter for this
* filter.
*
* @param request The servlet request we are processing
*/
protected String selectEncoding(ServletRequest request) {
return (this.encoding);
}
}
> From: Rupinder Singh Mazara <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Date: Wed, 06 Aug 2003 09:24:24 +0100
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: RE: Hindi i18n Iscii Font
>
> Try looking at icu4j it's a Open Source by IBM
>
> http://oss.software.ibm.com/icu4j/
>
> they have a cool api for doing internationalisation to any character set
>
>
>
>
>
> Rupinder
>
> -----Original Message-----
> From: Jason Lea [mailto:[EMAIL PROTECTED]
> Sent: 05 August 2003 22:34
> To: Struts Users Mailing List
> Subject: Re: Hindi i18n Iscii Font
>
> Hi Kiran,
>
> You need to set the character encoding for the JSP page/response. Java
> still thinks the response should be in the default encoding which is
> ISO-8859-4 (I think that is the Latin character set).
>
> I use UTF-8 encoding so that I can mix languages eg
> English/Japanese/French without having to worry about setting the
> correct page encoding for each page.
>
> So I do the same thing for the properties files eg
>
> native2ascii -encoding UTF-8 etc etc
>
> But at the top of each of my JSP pages I have this:
>
> <%@ page contentType="text/html; charset=UTF-8"%>
>
> In your case you probably have to change that to charset=ISCII91 if use
> that encoding.
>
> You can put this in your base action so you don't have to include in
> every page eg response.setContentType("text/html; charset=UTF-8").
>
> [Note: JSP Precompilation:
> The only problem I had with setting the content type in the action was
> when precompiling JSP pages. If there this line
> <%@ page contentType="text/html; charset=UTF-8"%>
> isn't in the JSP page or page fragment then Jasper would use the default
> encoding instead of UTF-8.]
>
> You will also need to set the character encoding on any request that
> submits data otherwise it will also be interpretted as ISO-8859-4. I
> use a filter an all request that just does this:
>
> request.setCharacterEncoding("UTF-8");
>
> (again change this to your character encoding ISCII91)
>
> This can't be done in an action because form beans are populated before
> they are given to the action. So you have a choice of using a filter,
> or overriding the RequestProcessor to do this.
>
> Hope this helps.
>
> --jason
>
>
> Kiran Kumar.M wrote:
>> Hi,
>> I need some help on I18n in Hindi,I am using Struts 1.1 and need to
>> display fonts in hindi (we use iscii charsets which are 8 bit)...
>> if i give the hindi value directly in my jsp it is working fine
>> but it is not able to read the same from the resource file ...
>> here are the steps i followed
>> first create applicationresources_hi.properties file
>> entered the following
>> prompt.hindi={��(r)�� {�i��
>> next converted the file
>> native2ascii -encoding ISCII91 srcfile dest file ...
>> this converts the {��(r)�� {�i�� to {\u092b\u093e\u090d\u096f\u092b
>> {\u092bi\u092b\u092b
>> (locale set to hi in Action)
>> in my jsp file
>> this does not work (nothing comes browser) when i get the value from
>> resource file although there is no problem with the english fonts in the
>> same file
>> <FONT SIZE="24" face="Somefont_installed_in_my_system">
>> <bean:message key="prompt.hindi" />
>> </font>
>> this works (hindi font comes on browser)
>> <FONT SIZE="24" face="Somefont_installed_in_my_system">
>> {��(r)�� {�i��
>> </font>
>> Can someone please help me
>>
>> Regards,
>> Kiran
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]