Pierre Métras wrote:

> Hi,
>
> The locale negociation to display localized messages occurs in the
> ActionServlet. So, a Struts application will not display localized messages
> before the first action.
>
> How can we negociate the locale desired by the user with the very first page
> displayed?
>
> Do we need a <setLocale> tag, so we can write an index.jsp page like the
> following:
> <html>
>     <head>
>         <setLocale />
>         <logic:forward name="firstPage" />
>     </head>
> </html>
> But this is not good because we have a configuration flag in web.xml and a
> tag for the first page...
>
> Or should each localizing tag check if the negociation has already occured,
> instead of ActionServlet?
>

This is certainly one approach -- and would be especially useful if people tend
to bookmark a page within your app rather than entering at the "front".

For the latter sort of people, one other strategy would be to declare a "welcome
page" for your application that actually invokes the controller servlet, so that
you get locale negotiation even the first time.

    <welcome-file-list>
        <welcome-file>setup.do</welcome-file>
    </welcome-file-list>

(I'm not sure every servlet 2.2 container supports a servlet as the welcome
page, but it's required in 2.3.)

>
> What do you think?
>
> Pierre Métras

Reply via email to