What about issues in regards to character encodings?

Some resources I have seen on the web, namely:

http://forums.itworld.com/webx?14@@.ee6bdcf/223!skip=185

claim that using UTF-8 encodings is still not the way to go when presenting 
pages.  Assuming this is the case, if we want, an English page, we need 
something like:

<%@ page contentType="text/html; charset=ISO-8859-5" %>

at the top of our JSP page, and the following for say Chinese:

<%@ page contentType="text/html; charset=Big5" %>

Do people have any experience with handling these issues, where a single JSP 
page is used for serving multiple locales which each may require different 
output encodings using struts+message tags?  I can imagine a couple of 
solutions, but haven't had any real practical experience yet. 

Cheers,
David

On Sat, 02 Dec 2000, Pierre Métras wrote:
> Hi Doug and others,
>
> > The server we're creating needs to be usable simultaneously by multiple
> > users in multiple languages. Our app uses Struts/JSP and the Model 2
> > architecture. What is the "best practice" or the "correct" Java/Struts
> > way of accomplishing this?
> >
> > Is there a way to use the same JSP pages, or is it best to have multiple
> > contexts (/en/, /fr/, etc)?
>
> Here is a brief presentation of what you can do with Struts to localize
> your application.
>
> With version 1.0, you can set the ActionServlet to do locale negociation.
> Just put in you web.xml file:
>       <init-param>
>         <param-name>
>           locale
>         </param-name>
>         <param-value>
>           true
>         </param-value>
>       </init-param>
>
> >From now, when a user connects to your application and he has defined a
>
> locale preference in his browser, Struts will set a locale in his user
> session. This locale is then used to select the appropriate message
> resource file when your application displays a message through the
> <bean:message /> tag.
> Different users can simultaneously use different languages, but generally
> (with Struts framework), a user only uses one language at a time.
>
> If you want to give to your user the ability to change the locale used, you
> need to write a bit of code that changes the Locale in the user session.
> And now, all the pages will use that new locale when displayed.
>
> If you have to display pages that keep the same structure from one language
> to the other, then the simpler way to localize your application is to use
> the <bean:message /> tag.
> Store all your strings in the appropriate resource file. Don't put
> formatting in your code, but in the message strings, and use parameters.
> For instance, taken from MessageFormat javadoc:
>      "At {1,time} on {1,date}, there was {2} on planet {0,number,integer}."
>
> Have a look at the java.text.MessageFormat and java.util.ResourceBundle
> documentation for more info. In particular, don't forget to double the
> quotes ' in the messages (like ''. This one turned me crazy...).
>
>
> When you want to include HTML formatting in your message other than line
> breaks, it's the time to think to create different pages for the different
> languages. I haven't investigated it yet, but I think that a lighter
> solution that language contexts can be found with conditional include,
> using the new Struts template tags.
> Depending on the locale, you <template:insert /> the corresponding
> localized page. This would allow a global framework for your application,
> but with various looks depending on the language selected by the user.
>
>
> Pierre Métras

Reply via email to