Sun Java System Portal Server 7.1 Developer Sample Guide

Chapter 13 Miscellaneous JSP and Template Information

This chapter contains the following sections:

This chapter contains miscellaneous information on using JavaServer PagesTM (JSPTM) and templates when customizing the Desktop.

Performing JSP Redirects

To perform redirects from the doedit.jsp page back to the edit.jsp page, use the following URL:


response.sendRedirect(p.getProviderContext().getDesktopURL(request).toString() +
 "?action=edit&provider=ipsdtJSPEditChannel" + "&targetprovider=" +
 p.getName() + "&reedit=true");

To return back to the Edit page, use the following, which does not hardcode the edit channel name.


String editChannel = request.getParameter("editChannelName");
response.sendRedirect(p.getProviderContext().getDesktopURL(request).toString() +
 "?action=edit&provider=<%=editChannel%>&targetprovider=" + p.getName() +
 "&redit=true");

JSP or Theme Color

The colors of a theme can be changed in two places: in the JSP or template file that uses the theme tag, and in the display profile using the GlobalThemes attribute.

If you change the color value in the JSP or template file, the Desktop uses this value and not what is in the GlobalThemes attribute.

For example, if you manually change the following background color in a JSP file


BGCOLOR="<dttheme:getAttribute name="borderColor"/>"

to


BGCOLOR="#FFFFFF"

then the Desktop shows white for border color, and the theme color is not used. There is no way the theme or the Desktop can detect this.

Recompiling JSPs

Every time you make a modification to a JSP file, you need to recompile. You do this by running the touch command on the modified container’s top-level JSP file.

For example, type touch tab.jsp.


Note –

A typical desktop will include content from several JSPs. However, if you make a modification to a non-toplevel JSP that has been included in a top level JSP, the included JSP will not be recomplied. The end result is your desktop changes will never be reflected.

If the top-level JSP is touched, the JSP engine recompiles all the relevant JSPs. If you cannot find the top level JSP, run the touch command on all JSPs in the directory, for example,


touch *.jsp

This modifies all JSPs, including the top-level JSP.

See JavaServer Page Caching Information for information on how to find the top-level (parent) JSP.


JavaServer Page Caching Information

When the system compiles JavaServer PagesTM (JSP), the result is only one JavaTM class per parent JSP. There is no compiled class for the static included JSPs. Thus, when you change an included JSP, you need to run the touch command on the parent JSP to recompile the parent JSP with the changed JSP. The Portal Server software JSP engine checks the last modification time on the compiled class and the JSP file to see if the JSP needs to be recompiled. In this way, the change takes effect immediately.

To find a JSP’s parent JSP, search in the JSP for the string <%@ include file="filename.jsp" %>. Some JSPs are dynamically included by using the <jsp:include page="header.jsp" flush="true"/> syntax instead of <%@ include file="header.jsp" %>. This syntax compiles header.jsp and generates a separate Java class.

The path to cached JSPs is constructed in such a way so that the compiled JSPs do not conflict with each other in multi-server instances, when multiple Desktop types contain the same JSPs and for multiple clientTypes and locales. So when JSPs are dynamically included, the touch command does not need to be run for the parent JSP.

Debugging JSPs

The JSP classes are created at PortalServer-DataDir/portals/portal-ID/desktop/compiled directory.

You can find compilation and runtime errors in the Desktop debug log at PortalServer-DataDir/portals/portal-ID/logs/portal-instance/portal.0.0.log.

Also, all JSPProvider based Desktop channels have a property called showExceptions. This property, by default, is set to false; setting it to true causes the JSP exception to show up as the content of the channel.

Dynamic Template Reloading

If you make changes to the Desktop templates, note that these templates are dynamically reloaded. The reload interval is by default set to thirty seconds. You can change the reload interval in the desktopconfig.properties file at PortalServer-DataDir/portals/portal-ID/config/ directory.

ProcedureTo Change the Template Reload Interval

  1. Log in to the Portal Server host and change directories to PortalServer-DataDir/portals/portal-ID/config.

  2. Open the desktopconfig.properties file and reset the templateScanInterval property value.

  3. Save and close the file.