KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > test > portlet > TestCachedContentPortlet


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.test.portlet;
10
11 import java.io.IOException JavaDoc;
12 import java.io.PrintWriter JavaDoc;
13
14 import javax.portlet.GenericPortlet;
15 import javax.portlet.PortletException;
16 import javax.portlet.PortletSecurityException;
17 import javax.portlet.PortletSession;
18 import javax.portlet.RenderRequest;
19 import javax.portlet.RenderResponse;
20
21 /**
22  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
23  * @version $Revision: 1.2 $
24  */

25 public class TestCachedContentPortlet extends GenericPortlet
26 {
27    public void render(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException JavaDoc
28    {
29       PortletSession session = request.getPortletSession();
30       Integer JavaDoc counter = (Integer JavaDoc)session.getAttribute("COUNTER");
31       counter = new Integer JavaDoc(counter == null ? 0 : counter.intValue() + 1);
32       session.setAttribute("COUNTER", counter);
33       //
34
response.setContentType("text/html");
35       PrintWriter JavaDoc writer = response.getWriter();
36       writer.print("The counter value is " + counter);
37       writer.close();
38    }
39 }
40
Popular Tags