Anda di halaman 1dari 2

Creating URLs to portlet resources

Portlet JSPs cannot link directly to content (for example, images, applets, other JSPs, or other
resources) within the portlet's WAR directory structure. Instead, they have to use the services of the
portlet container to create portlet URLs from which the content can be accessed. Use the encodeURL()
method of the PortletResponse to access content within the portlet WAR structure. The following
examples are used in the View World portlet samples.

<img src='<%=renderResponse.encodeURL(renderRequest.getContextPath() +
"/images/earth.jpg")%>'
alt="Earth" />

What is a portlet caching?


Caching is a important technique for improving the performance of a system. The portlet and web
containers in WebSphere Application Server both support server-side caching. With server-side
caching, the content of a servlet or portlet is stored in a local cache on the server so that further requests
do not need to run the servlet or portlet.
Portlet caching is more complex than servlet caching because portlet fragments contain links pointing
to the full page. However, in order to be cachable fragments, they must only contain artifacts with the
scope of the fragment. The challenge for portal frameworks is to only cache the fragment without any
dependencies on artifacts outside of the fragment.
With WebSphere Portal, the fragments are assembled later using its aggregation framework. The
portlet container in WebSphere Application Server also takes care of such complexities; it factors out
content which has a scope that is different from the fragment, and then re-assembles the complete
content whenever cached content is requested again.
This section shows how you can turn on portlet fragment caching using the administrative console or
with the scripting interface. At the end of this section, you how to use the WebSphere Application
Server cache monitor with an example portlet in a demonstration of the cache infrastructure.
In the portlet.xml file:
<portlet-name>StdWorldClock</portlet-name>
<portlet-class>com.ibm.wps.portlets.worldclock.WorldClockController</portlet-
class>
<expiration-cache>130</expiration-cache>
<supports>

Create a second file cachespec.xml and keep it in the WEB-INF directory to turn on caching.
<cache>
<cache-entry>
<class>portlet</class>
<name>StdWorldClock</name>
<property name="consume-subfragments">true</property>
<cache-id/>
</cache-entry></cache>

Enable Portlet Fragment Cache in the Application server after logging in to the admin console.

What are XMLAccessScripts?


WebSphere Portal configuration client XML Access allows the Portal administrator to update and
maintain a portal application installation and to easily maintain settings without having to remember
which Portal administration portlet to use. For example, you can install a portlet, set security, and
change parameters in one easy step using the Portal configuration client XML Access tool.

Use the Portal configuration client to update global WebSphere Portal settings, such as portlet services
settings that are found in the PortletServices.properties file. This also allows you to
change the portlet services implementation. In a well-defined portlet service, a developer can change
the portlet service implementation without changing the portlet service interface. The portlet view layer
is independent of any changes to the underlying model layer.

Another advantage of using XML Access scripts is that in a production environment with several portal
servers instances for development, staging, quality assurance, and production, the portal administrator
can maintain one set of scripts for each installation. The administrator can also make any server
dependent changes in the deploy scripts without having to change the base code.