Sun Java logo     Previous      Contents      Index      Next     

Sun logo
Sun Java System Portal Server 6 2004Q2 Developer's Guide 

Chapter 28
Templates and JSPs

This chapter contains the following sections:

This chapter addresses the Desktop templates and JavaServer Pages™ (JSP™) in the Portal Server software that can be translated to support localization.

Desktop Templates

Template Files

The /etc/opt/SUNWps/desktop/desktoptype directory contains templates that are used to generate the Desktop pages. For each directory contained in this directory, a new directory for the locale must be created. The directory name must contain the existing directory with an underscore and the name of the locale; for example, /etc/opt/SUNWps/desktop/default is translated to /etc/opt/SUNWps/desktop/default_locale.


The desktoptype refers to the Desktop type attribute which is now a comma separated list. The usage of this attribute is described in Chapter 1 of the Portal Server Desktop Customization Guide.

All of the file names can remain the same. Only files that require translation must be created in the locale-specific directory. If a file is not found in the locale-specific directory, it is automatically taken from the directory that does not have the locale specifier.

Template files are mostly markup text with embedded tags that specify substitutions to be performed at runtime. The tags have the form [...]. The tags should not be modified during the translation process.

Each template file is encoded using Java™ Unicode encoding where non-ASCII characters are represented with \uXXXX notation. Here the \uXXXX is the hexidecimal representation of the Unicode value for the character. This type of file can be created from a native file using the Java native2ascii program available in the Java™ Development Kit (JDK) 1.3.1 package that is shipped with the Portal Server software.


JSP files end with the .jsp suffix. The encoding for each top-level JSP file is specified using a header at the top of the file. The header must look like the following:

<%@ page contentType="text/html; charset=encoding" %>

where encoding is the desired encoding such as UTF-8 or EUC-JP. Note that this is only for top-level JSP files. JSPs that are statically included by other JSPs must use the encoding of the including JSP. That is, JSPs that are statically included by other JSPs using

<%@ include file="relativeURL" %>

must use the encoding of the including JSP. JSPs that are dynamically included using:

<jsp:include page="{ relativeURL | <%= expression %>}" flush="true" />

must have their own page directive that contains the encoding.


If image files referenced by the existing templates are inappropriate for a locale, the references can be changed to refer to new files. The new file must be placed in the document root of the web container at portal-server-install-root/SUNWps/web-src directory and then deploy it with the portal-server-install-root/SUNWps/bin/deploy redeploy command. Or, you can deploy a new WAR file into the location of your choice.

File Lookup Mechanism

Desktop content can be customized based on the following factors:

The DesktopServlet performs a search for a localized file before selecting a default. In order to perform the search, the DesktopServlet uses the user’s locale attribute in the user’s directory entry (or preferredLocale attribute in the Sun Java System Identity Server) and searches for the file. For more information on the search order, see Presentation Method.

Locales are searched from more to less specific. For example, for a locale setting of en_US_WE, the search order would be: en_US_WE, en_US, en. If the locale-specific property is not found, then the non-locale-specific version is returned (if it exists).

Previous      Contents      Index      Next     

Copyright 2004 Sun Microsystems, Inc. All rights reserved.