JSP is often the most convenient way to construct the view for a portlet. A portlet can dispatch to a jsp to provide the view in a fashion very similar to a servlet or a classic model-2 architecture like Struts.
The dispatch()
method of the HelloWorldPortlet use the Portlet API to dispatch to a view, and the render()
method does the dispatch.
The standard JSP functionality, including JSTL and EL are available in a JSP that a portlet uses for the view.
Portlet request attributes, set in the portlet with
request.setAttribute( "name", value )
, are available in the JSP
as request attributes request.getAttribute("name")
and EL variables ${'${'}name}
.
There is also a portlet JSP tag library that defines a small number of portlet specific tags. The most useful of the portlet tags are those that are provided for creating render and action urls.
The HelloWorldPortlet is written so that it provides a default path for the jsp that can be overriden by an . This is a flexible architecture, if a different jsp page is desired for the view it can be specified without modifying the source code.