<document>
<deftable>
Portlet
web-app configuration
</deftable>

Just like Servlets a Portlet does not maintain state within the Portlet object. Many requests, from many different users, may be using an instance of a portlet at the same time.

In this tutorial, the "identity" and "color" are two values to contain the state of the portlet. The portlet provides links to change the color or identity, and maintains the identity and color from request to request.

The value of a render parameter is obtained from the request object using `request.getParameter(name)`.

public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { String identity = request.getParameter("identity"); if (identity == null) identity = "World"; String color = request.getParameter("color"); if (color == null) color = "silver"; ... out.println("Hello, " + identity + "."); out.println("Your favorite color is " + color); ...

The value of a render parameter can be changed on a subsequent request with the use of response.createRenderURL(). `response.createRenderURL()` returns a PortletURL. The `PortletURL` is used to set render parameters for the next request, the `toString()` method is used to generate the appropriate url.

... String identity = request.getParameter("identity"); String color = request.getParameter("color"); ... // url links to change the name PortletURL harryUrl = response.createRenderURL(); harryUrl.setParameter("identity", "Harry"); harryUrl.setParameter("color", color); PortletURL ronUrl = response.createRenderURL(); ronUrl.setParameter("identity", "Ron"); ronUrl.setParameter("color", color); ... out.println("<li><a href='" + harryUrl.toString() + "'>Harry</a>"); out.println("<li><a href='" + ronUrl.toString() + "'>Ron</a>"); ...
</document>