You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Stephen Riek <st...@yahoo.co.uk> on 2002/11/25 00:42:38 UTC

help with multilingual JSP sites pls. using a Filter to rewrite the URL ?

I'd like for a request to "<webapp>/en/Folder/File" to be
sent to "<webapp>/Folder/File" but with a parameter 'lang'
 set to 'en'. 

Likewise, a request to "<webapp>/fr/Folder/File" to be 
sent to "<webapp>/Folder/File" but with a parameter 'lang' 
set to 'fr'.

Is this possible with Filters?

If not, is there any way to accomplish this within Tomcat 
so that it works for any number of directories and 
subdirectories. The reason I want to do this is to avoid 
copying/pasting an entire sitemap to support a 
second language - I know that some people create a site 
in English then copy/paste the directory tree into another
directory (eg. '/fr', '/de/', '/cn/') to support a
 second language but this is not scalable and difficult to 
maintain. How do you circumvent doing such things ? 

Other mechanisms I've looked at are Apache rewrite rules 
but they're very complicated and I'd also like to make this
work independent of Apache, and preferably for all servlet
engines.

Stephen.





---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs

Re: help with multilingual JSP sites pls. using a Filter to rewrite the URL ?

Posted by Kwok Peng Tuck <pe...@makmal.com>.
Why don't you look up on resource bundles instead?

Stephen Riek wrote:

>Sorry, I'm not making myself clear here.  My JSPs do exactly as you suggest 
>so that I have one JSP serving up French and English pages, depending on 
>the language that the user selected on my site.
>Here is the problem explained very simply. I have a sitemap as follows:
>/en
>--> /Products
>      --> Toys/index.jsp
>      --> Decoration/index.jsp
>/fr
>--> /Products
>      --> /Toys/index.jsp
>      --> /Decoration/index.jsp
>
>As you can see, this is braindead. If I wish the functionality of the English section 
>of the site to be the same as that of the French part of the site, then any change
>to a JSP in the 'en' part must be repeated within the 'fr' site. This is not 
>scalable and is tedious. 
>
>Instead, it would be much better if I had one site structure which served up the
>whole site.
>
>/Products
>   --> /Toys/index.jsp
>    --> /Decoration/index.jsp
>
>Any changes to functionality only have to be made in one place and both the
>french viewers and english viewers will experience the same user experience, 
>just in different languages. (I use the properties files as you suggest to 
>serve up different languages).
>
>The problem however is "how does /Products/Toys/index.jsp" know whether
>the user is viewing in English or French ? The easy way would be to have the
>user select a language on entering the site and then store the language 
>preference in a cookie which I check before serving up pages. However, 
>users may access the site from a search engine or from direct URLs due to
>promotions.  I would like a request for /en/Products/Toys/index.jsp to be 
>sent to /Products/Toys/index.jsp but with a 'lang' parameter set to 'en'. 
>Likewise for the french part of the site. 
>
>Surely somebody has had to encounter this sort of problem in dealing with
>pan-European sites ?
>
>Stephen.
>
> 
>
> Triptpal Singh Lamba <tr...@cs.sunysb.edu> wrote:One way you can do this is using property files.
>
>Prop_ file name _ language code.properties
>
>So for say abc.jsp , you have abc_en.properties and abc_fr.properties.
>
>At comple time the JSP calls a class you write at server which gives say String languageCode  = ObjectName.getLaguageCode(param 1 ,param 2);  %>
>
>Then all JSP elements are picked from there.
>Thanks
>Tript Singh
>
>
>
>
>
>---------------------------------
>With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs
>
>  
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: help with multilingual JSP sites pls. using a Filter to rewrite the URL ?

Posted by Stephen Riek <st...@yahoo.co.uk>.
Sorry, I'm not making myself clear here.  My JSPs do exactly as you suggest 
so that I have one JSP serving up French and English pages, depending on 
the language that the user selected on my site.
Here is the problem explained very simply. I have a sitemap as follows:
/en
--> /Products
      --> Toys/index.jsp
      --> Decoration/index.jsp
/fr
--> /Products
      --> /Toys/index.jsp
      --> /Decoration/index.jsp

As you can see, this is braindead. If I wish the functionality of the English section 
of the site to be the same as that of the French part of the site, then any change
to a JSP in the 'en' part must be repeated within the 'fr' site. This is not 
scalable and is tedious. 

Instead, it would be much better if I had one site structure which served up the
whole site.

/Products
   --> /Toys/index.jsp
    --> /Decoration/index.jsp

Any changes to functionality only have to be made in one place and both the
french viewers and english viewers will experience the same user experience, 
just in different languages. (I use the properties files as you suggest to 
serve up different languages).

The problem however is "how does /Products/Toys/index.jsp" know whether
the user is viewing in English or French ? The easy way would be to have the
user select a language on entering the site and then store the language 
preference in a cookie which I check before serving up pages. However, 
users may access the site from a search engine or from direct URLs due to
promotions.  I would like a request for /en/Products/Toys/index.jsp to be 
sent to /Products/Toys/index.jsp but with a 'lang' parameter set to 'en'. 
Likewise for the french part of the site. 

Surely somebody has had to encounter this sort of problem in dealing with
pan-European sites ?

Stephen.

 

 Triptpal Singh Lamba <tr...@cs.sunysb.edu> wrote:One way you can do this is using property files.

Prop_ file name _ language code.properties

So for say abc.jsp , you have abc_en.properties and abc_fr.properties.

At comple time the JSP calls a class you write at server which gives say String languageCode  = ObjectName.getLaguageCode(param 1 ,param 2);  %>

Then all JSP elements are picked from there.
Thanks
Tript Singh





---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs

Re: help with multilingual JSP sites pls. using a Filter to rewrite the URL ?

Posted by Triptpal Singh Lamba <tr...@cs.sunysb.edu>.
One way you can do this is using property files.

Prop_ file name _ language code.properties

So for say  abc.jsp , you have abc_en.properties and abc_fr.properties.

At comple time the JSP calls a class you write at server which gives say <%
String languageCode  = ObjectName.getLaguageCode(param 1 ,param 2);  %>

Then all JSP elements are picked from there.
Thanks
Tript Singh

----- Original Message -----
From: "Stephen Riek" <st...@yahoo.co.uk>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Sunday, November 24, 2002 6:42 PM
Subject: help with multilingual JSP sites pls. using a Filter to rewrite the
URL ?


>
> I'd like for a request to "<webapp>/en/Folder/File" to be
> sent to "<webapp>/Folder/File" but with a parameter 'lang'
>  set to 'en'.
>
> Likewise, a request to "<webapp>/fr/Folder/File" to be
> sent to "<webapp>/Folder/File" but with a parameter 'lang'
> set to 'fr'.
>
> Is this possible with Filters?
>
> If not, is there any way to accomplish this within Tomcat
> so that it works for any number of directories and
> subdirectories. The reason I want to do this is to avoid
> copying/pasting an entire sitemap to support a
> second language - I know that some people create a site
> in English then copy/paste the directory tree into another
> directory (eg. '/fr', '/de/', '/cn/') to support a
>  second language but this is not scalable and difficult to
> maintain. How do you circumvent doing such things ?
>
> Other mechanisms I've looked at are Apache rewrite rules
> but they're very complicated and I'd also like to make this
> work independent of Apache, and preferably for all servlet
> engines.
>
> Stephen.
>
>
>
>
>
> ---------------------------------
> With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits
your needs
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>