Of course, a portlet can contain more than one JSP.
You can display any JSP you want using PortletRequestDispatcher in doView (or doHelpor doEdit):
protected void doView(RenderRequest req, RenderResponse resp)
throws PortletException, IOException, UnavailableException {
resp.setContentType("text/html");
String myview = req.getParameter("myview");
String view = "/WEB-INF/jsp/" + (myview==null ? "bar" : myview) + ".jsp";
PortletRequestDispatcher dispatcher =
getPortletContext().getRequestDispatcher(view);
dispatcher.include(req, resp);
}
To set the view, you can use parameter . In JSP with links, you will need to use the portlet API to create / encode portlet links. For example:
<portlet:renderURL>
<portlet:param name="myview" value="foo"/>
</portlet:renderURL>
(I really didn’t know about JSR286 / Portlet 2.0 - this material should work with JSR168 / Portlet 1.0, so you should check out the new API if you use it.)
source
share