Portlet URLs
Overview
You can request a portlet directly through an URL to display its content without portal aggregation. The PortletServingServlet servlet registers each Web application that contains portlets. It is similar to the FileServingServlet servlet of the Web container that serves resources. The PortletServingServlet servlet allows you to directly render a portlet into a full browser page by a URL request.
You can invoke each portlet by its context root and name
http://<host>:<port>/<context-root>/<portlet-name>For example...
http://localhost:9080/portlets/TestPortlet1The context root identifies the WAR file that contains the portlet. The portlet name uniquely identifies the portlet with a portlet application of a WAR file. The DefaultDocumentFilter servlet only supports HTML, UTF8 encoding and an extended URL form based on the basic URL form as shown above.
You can only display one portlet at a time using the PortletServingServlet servlet. To aggregate multiple portlets on the page, use the aggregation tag library.
Because a portlet only delivers fragment output whereas a servlet usually delivers document output, a mechanism is introduced to convert the fragment into a document, called the PortletDocumentFilter filter. By default, the PortletDocumentFilter filter only supports converting HTML. The conversion is implemented using a servlet filter before the PortletServingServlet servlet is initiated to return the portlet‘s content inside of a document. This default document servlet filter only applies to URL requests, not for includes or forwards using the RequestDispatcher method. You can create servlet filters to support other markups additional document servlet filters.
The PortletServingServlet servlet does not persist portlet preferences in a XML file or database, instead, it persists portlet preferences by inserting them directly into a cookie.
Portlet URL syntax
You can add additional portal context such as portlet mode or window state. You can access the PortletServingServlet servlet by using a URL mapping that has the following structure:
http://host:port/context/portlet-name[/portletwindow[/ver[/action][/mode][/state][rparam][/?name]]]Any differing URL structure results in an exception...
com.ibm.wsspi.portletcontainer.InvalidURLExceptionEmpty strings are not permitted as parameter values and creates an exception...
InvalidURLExceptionThe following is a list of valid parameters:
Here are some sample valid URLs:
- http:// host:port/context/portlet-name
Minimum URL required to access a portlet.
A default portlet window called ‘default’ is created. The portlet-name variable is case-sensitive.
- /portletwindow
This parameter identifies the portlet window. Set this parameter if you choose to add more portal context information to the URL.
- /ver=major.minor
Vof the portlet API.
Set this parameter if you choose to add more portal context information to the URL. Only the version '1.0’ is allowed. Any differing version creates an InvalidURLException exception. Optional
- /action
Required if you call the action method of the portlet.
The action parameter causes the action process of the portlet to be called. After the action has been completed, a redirect is automatically issued to call the render process. To control the subsequent render process, a document servlet filter can set a request attribute with name 'com.ibm.websphere.portlet.action' and value 'redirect' to specify that the portlet serving servlet directly returns after action without calling the render process.
- /mode=view | edit | help | custom-mode
Defines the portlet mode that is used to render the portlet. The default mode is ‘view’. The value is not case-sensitive, For example, ‘View’, ‘view’ or ‘VIEW’ results in the same mode. Optional
- /state=normal | maximized | minimized | custom-state
This optional parameter defines the window state that is used to render the portlet. The default state is ‘normal’. The value is not case-sensitive, For example, ‘Normal’, ‘normal’, or ‘NORMAL’ results in the same state.
- * [ /rparam=name *[=value] ]
This optional parameter specifies render parameters for the portlet. Repeat this parameter chain to provide more than one render parameter. For example, /rparam=invitation/rparam=days=Monday=Tuesday
- ?name=value&name2=value2 …
Query parameters may follow optionally. They are not explicitly supported by the portlet container, but they do not invalidate the URL format.
http://localhost:9080/sample/WorldClock http://localhost:9080/sample/WorldClock/myPortlet/ver=1.0/mode=edit/rparam=timezone=UTC http://localhost:9080/sample/WorldClock/myPortlet/ver=1.0/action/state=maximized?timezone=UTC
Related concepts
Portlet container
Portlet aggregation using JavaServer Pages
Portlet preferences
Related tasks
Task overview: Managing portlets
Related Reference
Portlet container settings