views:

716

answers:

2

I want to create own header.jsp file instead of the one included in the JBoss Portal 2.6 but have to support the locale set by the user.

The original header.jsp does not contain any i18n and I don't know how to do it, especially how to get the actual locale.

A: 

You can look to Thread.currenThread method to see the user's lang.

After that you have to a framework to implement i18n, ex : struts or jsf.

Lurtz
I don't understand you. How helps the currentThread to get the user's language?
laszlot
+1  A: 

In header.jsp, use a scriptlet:

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%
   locale = request.getLocale()  // get the user's locale from the HttpServletRequest

%>

and then set the property bundle:

<fmt:setLocale value="<%= locale %>" />

<fmt:setBundle basename="header" />

And then you can create

   header_en.properties
   header_de.properties

for customized messages.

johnbr
Rather use `<fmt:setLocale value="${pageContext.request.locale}" />`. No need for scriptlets.
BalusC