portals-jetspeed-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Evans <aaronmev...@yahoo.ca>
Subject Re: JSP Stand-alone portlet help
Date Fri, 06 Jan 2006 17:48:51 GMT
Scott T Weaver <scotts-jetspeed-list <at> binary-designs.net> writes:

> Well you can't just point to a jsp.  You need to write at least one portlet
> then have it include the relevant jsp using
> PortletRequestDispatcher.include().  Direct rendering of jsp pages is not
> supported in the portlet spec as it is in the servlet spec.
> -Scott

Scott is quite right.  Let's be clear here: You have stand-alone JSPs, not
stand-alone JSP portlets. No modern containers even support deploying just
JSPs to a doc root anyway, they always must be part of a web-application.

What you need to do is add them to a web-application that is also a portlet
application as per the tutorial.

Here is a very simple portlet that you can re-use for all your JSPs:

********** CODE BEGIN ***********

package com.mycompany.portlet;

import java.io.IOException;

import javax.portlet.GenericPortlet;
import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

public class SimpleContentPortlet extends GenericPortlet
	private String viewPage="view.jsp";
	public void init(PortletConfig config) throws PortletException 
        	this.viewPage = config.getInitParameter("ViewPage");
	public void doView(RenderRequest request, RenderResponse response) 
throws PortletException, IOException
		PortletContext context = getPortletContext();
		PortletRequestDispatcher rd = 
        rd.include(request, response);

********** CODE END ***********

By default, this will attempt to include a jsp named view.jsp in the
root of your web-app.  

So, in your portlet.xml, use an init param to specify a 'ViewPage' param and 
set it to the relative path of one of your JSPs (relative that is to the root 
of your web app directory).

Note that only view is supported here, but doing the same thing for
edit and help is trivial.

So, for each of your JSPs, add a distinct portlet definition in your
portlet.xml with a distinct name.  For the portlet class, you would use

Then just add to PSML as described above.

To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org

View raw message