Basic portlet development

zhaozj2021-02-16  54

1 Simple portlet for static content

Package com.ibm.wps.samples.Weather;

Import java.io. *;

Import org.apache.jetspeed.portlet. *;

Import org.apache.jetspeed.portlets. *;

/ ** * WeatherPortlet.java? Simple Example to Display Weather. * /

Public class weatherportlet extends abstractportletlet {

Public void init (portletconfig portletconfig) throws unavailableException {

Super.init (portletconfig);

}

Public Void Service (PortletRequest Request, PortletResponse Response) throws portletException, ioException

{

PrintWriter Writer = response.getwriter ();

Writer.println ("The Weather IS 78 Degress);

}

This is a very basic portlet, which is just output static messages "The Weather IS 78 Degrees". It shows the basic class interface AbstractPortlet, you need to create a new portlet application to inherit this interface. Like servlet, portlet has a service method that returns content to the portlet window, you must overwrite this method. This example shows how to get printwriter from the portletResponse object to write HTML content to the output stream.

转载请注明原文地址:https://www.9cbs.com/read-16971.html

New Post(0)