Page wrongly displays in Spanish only once

  • Thread starter Thread starter Phil Powell
  • Start date Start date
P

Phil Powell

I have a case whereby a webpage will, for some bizarre reason, display
in Spanish even though the end-user is insisting that they are not
changing their IE language settings; when they refresh the page it
reverts back to English and stays that way.

I am tasked with investigating as to why this has ever occurred as it
seems to occur with one particular JSP page that is reading initially
from

String acceptedLang = (String) request.getHeader("accept-language");

Has anyone out there ever encountered anything like this before?
Please let me know.

Thanks
Phil
 
I have a case whereby a webpage will, for some bizarre reason, display
in Spanish even though the end-user is insisting that they are not
changing their IE language settings; when they refresh the page it
reverts back to English and stays that way.

I am tasked with investigating as to why this has ever occurred as it
seems to occur with one particular JSP page that is reading initially
from

String acceptedLang = (String) request.getHeader("accept-language");

Has anyone out there ever encountered anything like this before?
Please let me know.

Thanks
Phil

Can you provide the code that will trigger problem?
 
Can you provide the code that will trigger problem?- Hide quoted text -

- Show quoted text -

Here you go. If you need more I will have to see as I am not sure of
the legality (or security permissiveness) of publically posting entire
template code, however, this snippet handles the header issue:

<pre>
<code>
[JSP]
<%
String savedAcceptLang = (String)
request.getSession().getAttribute("savedAcceptLang");
String acceptLang = (String) request.getHeader("accept-language");

if (acceptLang.indexOf(";") != -1) {
// Get rid of the extra data at the end of the string

acceptLang = acceptLang.substring(0, acceptLang.indexOf(";"));
}

if (acceptLang.indexOf(",") != -1) {
// If a comma exist, then more than one language is specified.
// Split the string and get their first choice

StringTokenizer st = new StringTokenizer(acceptLang, ",");
acceptLang = st.nextToken();
}

// If the translated text has already been retrieved, then
// don't make another trip to the db. Trip is made
// if a change in the language selection is detected.
// One problem to this is that any new translations won't show
// up until the user closes the browser and starts a new session.

if (!acceptLang.equals(savedAcceptLang)) {
request.getSession().setAttribute("savedAcceptLang", acceptLang);

initLang(acceptLang);
}
%>
[/JSP]
</code>
</pre>
 
Can you provide the code that will trigger problem?- Hide quoted text -
- Show quoted text -

Here you go. If you need more I will have to see as I am not sure of
the legality (or security permissiveness) of publically posting entire
template code, however, this snippet handles the header issue:

[snipped code]

Do you have the code for initLang? And is acceptLang being passed as
the correct value?
 
On Dec 18, 3:58 pm, (e-mail address removed) wrote:
Here you go. If you need more I will have to see as I am not sure of
the legality (or security permissiveness) of publically posting entire
template code, however, this snippet handles the header issue:
[snipped code]

Do you have the code for initLang? And is acceptLang being passed as
the correct value?- Hide quoted text -

- Show quoted text -

initLang() is a method calling upon a database query whose content I
can't reveal due to its being sensitive government data, sorry (the
query itself, that is). acceptLang is the correct value.

What we wound up doing was to put response.setHeader() values to force
client-side flushing (Pragma, expiration in the past, etc.), along
with moving some HTML code down below the JSP that uses initLang() to
ensure all HTML is rendered after any header manipulation. Between
that and flushing the Vignette template cache, it works now!
 
Back
Top