You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Julien Martin <ju...@wanadoo.fr> on 2003/09/24 13:00:47 UTC

SOS JSTL

Hello,

I am developing an application that uses Jstl for internationalization.  I
store a string called "lang" in a request attribute (${requestScope.lang}).
This string is either "fr" or "es".
My page is sometimes in french even though the lang attribute is "es" and
vice versa.  It seems as if the  ${requestScope.lang} is ignored.

Can anyone help please?

Thanks in advance,

Julien.


Here is the full content of my jsp:

******************************
<%-- ==================================================

Index Page

================================================== --%>

<%@ page import ="com.parispano.latinamericaguide.*" %>

<%@ taglib uri="/WEB-INF/c.tld" prefix="f" %>

<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>

<%@ taglib uri="/WEB-INF/latinamericaguide.tld" prefix="po" %>

<%

/* We retrieve the Countries object from the servlet context. */

ServletContext sc = getServletContext();

Countries cs = (Countries)sc.getAttribute("countries");

/* We apply the sorting criterion. */

String sortCriterion = request.getParameter("sortCriterion");

Country[] countryArray = cs.getArray(sortCriterion);

%>

<fmt:setLocale value="${requestScope.lang}"/>

<fmt:bundle basename="com.parispano.latinamericaguide.resources.labels">

<html>

<head>

<title><fmt:message key="title_index_jsp"/></title>

<link rel="StyleSheet" type="text/css" href="css/latinamericaguide.css"/>

</head>

<body>

<div id="logo_home">

<img src="./media/logo_atlas.gif" alt="">

</div>

<div id="advertisement">

<jsp:directive.include file="pages/modules/indexmodule.jsp" />

</div>

<div id="left-column">

hola toto

</div>



<div id="country-list-box">

<div id="language">

current language: ${requestScope.lang}<br />

<a
href=LanguageServlet?url=<%=request.getRequestURL()%>&lang=<po:RetrieveOther
Language locale="${requestScope.lang}"/>>Change Language</a><br /><br />

</div>

<div id="top-left">

<div id="top-right">

</div>

</div>

<div id="title">

<img src="./media/<po:I18nlizeImage imageName="atlas_latino"
locale="${requestScope.lang}"/>" alt="">

</div>

<div id="sortingForm">

<jsp:directive.include file="pages/sorterForm.jsp" />

</div>



<table>

<tr>

<th><fmt:message key="country_index_jsp"/></th>

<th><fmt:message key="capital_index_jsp"/></th>

<th><fmt:message key="landarea_index_jsp"/></th>

<th><fmt:message key="population_index_jsp"/></th>

<th><fmt:message key="gdp_index_jsp"/></th>

<th><fmt:message key="gdp_per_capita_index_jsp"/></th>

<th><fmt:message key="more_index_jsp"/></th>

</tr>



<%

int rowCol=0;

for(int i=0; i<countryArray.length; i++){

rowCol++;

Country country = (Country)countryArray[i];

out.println("<tr " +
((rowCol%2==0)?("class=\"evenRow\""):("class=\"oddRow\"")) + ">");

out.println("<td class=\"countryName\">" +country.getName() + "</td>");

out.println("<td class=\"countryCapital\">" +country.getCapital() +
"</td>");

out.println("<td class=\"number\">" + country.getFormattedLandArea() +
"</td>");

out.println("<td class=\"number\">" +country.getFormattedPopulation() +
"</td>");

out.println("<td class=\"number\">" +country.getFormattedGdp() + "</td>");

out.println("<td class=\"number\">" +country.getFormattedGdp_per_head() +
"</td>");

out.println("<td><a class=\"more\" href=\"pais.jsp?countryID=" +
country.getId() + "\">más...</a></td>");

out.println("</tr>");

}

%>

</table>





<div id="bottom-left">

<div id="bottom-right">

</div>

</div>



<jsp:directive.include file="./pages/footer.jsp"/>

</div>

<br />







</body>

</html>

</fmt:bundle>

******************************