-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew,

On 5/7/2009 3:35 PM, Andrew Davidson wrote:
> My main website is in
> English. I want to have a landing page in Spanish that describes my website
> and invites the user to click through the English version of the web site.
> Any idea how I set this up using Tomcat? The bulk of our web site is static
> html pages.
> 
> Some one sent me a link about how to do this using the Apache web server so
> that it check the Accept-Language of the http header 
> 
> http://developers.sun.com/dev/gadc/technicalpublications/articles/apache.html
> 
> I have not been able to find a similar discussion for how to configure
> Tomcat to get similar behavior

You can think about mod_* as a servlet in Tomcat that doesn't yet exist.
You can implement any capability you need to match something that Apache
httpd does with one of its modules.

> Do I have to replace index.html with a servlet that checks the value of
> Accept-Language and generates a redirect to something like index.html.en or
> index.html.[es]

That sounds like a decent idea.

Andre-John suggests using request.getLocale().getLanguage() to determine
where to go. I would recommend getting the raw Accept-Language header
information and checking that against the languages you support. You
don't want to blindly redirect to index.html.zh when you only have
index.html.en and index.html.es.

You may be able to leverage urlrewrite (http://tuckey.org/urlrewrite/)
to do your heavy-lifting. I think something like this would work:

<rule>
  <!-- Attempt to find Spanish without an English preference over it -->
  <condition name="Accept-Language"
        value="(en){0}?.*es(_[A-Z][A-Z])?" />
  <from>/index.html</from>

  <!-- Don't try any more rules -->
  <to last="true" type="redirect">/index.html.es</to>
</rule>

<!-- Default rule: go to English for everyone else -->
<rule>
  <from>/index.html</from>
  <to type="redirect">/index.html.en</to>
</rule>

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkoIlSMACgkQ9CaO5/Lv0PDqlwCdHP+bzdw6m4XMv05EnivZbtnk
7+gAn1Q4A4aOjCBjINhQQTUlApHUO4ND
=ammP
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to