JSR286: defineObjects Tag (variables available in the JSP)

I have got lot of queries about the variables to be used in JSP page when included from within a Portlet. Also few problems were reported that the new variables introduced in JSR 286 are not working as expected. Let me explain both.

JSR 168 (Portlet 1.0)

In JSR 168 only three variables are defined:
  • RenderRequest renderRequest
  • RenderResponse renderResponse
  • PortletConfig portletConfig
In order to use them you must refer to the taglib uri and use defineObject Tag in the JSP page as follows

<%@ taglib uri=”http://java.sun.com/portlet” prefix=”portlet”%>


JSR 268 (Portlet 2.0)

In JSR 286 following variables are defined:
  • RenderRequest renderRequest and RenderResponse renderResponse (if the JSP is included from render method)
  • ResourceRequest resourceRequest and ResourceResponse resourceResponse (if the JSP is included from serveResource method)
  • ActionRequest actionRequest and ActionResponse actionResponse (if the JSP is included from processAction method)
  • EventRequest eventRequest and EventResponse eventResponse (if the JSP is included from processEvent method)
  • PortletConfig portletConfig
  • PortletSession portletSession (returns an existing session or null if no session exists)
  • Map<String, Object> portletSessionScope (provides access to the portletSession attributes)
  • PortletPreferences portletPreferences (provides access to the portlet preferences)
  • Map<String, String[]> portletPreferencesValues (provides access to the portlet preferences as a Map)

In order to use the variables you must refer to a different taglib uri and use defineObject Tag in the JSP page as follows

<%@ taglib uri=”http://java.sun.com/portlet_2_0” prefix=”portlet”%>




Hi Deepak,

I am just not able to access renderRequest Object and <portlet:namespace/>in the View JSP ,

can you please let me know if there is still any problems.

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ page import="javax.portlet.\*"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

<portlet:defineObjects />

<%PortletPreferences prefs = renderRequest.getPreferences();%>

In NetBeans, renderRequest is not Identified. it say's cannot find symbol

using PortalPack2.0.1 Plugin with GlassFish v2-ur2


Posted by Samar on August 24, 2008 at 08:32 PM IST #

Hi All,

I am Fairly new to this environment, i have followed the steps for integrating netbeans 6.1, plugins for openportal portlet container and glassfish-v2ur2 , everything installed fine.

however in the IDE i have 2 issue so far,

1) my "renderRequest" Object is not identified it say's "cannot find symbol",
i have included <portlet:defineObjects/> at the top ,is there a BUG still.

<portlet:renderURL var="aURL"><portlet:param name="showReviewPage" value="showReview"/></portlet:renderURL>
<a href="<%=aURL.toString() %>" review</a>

aURL cannot be identified. it simply say's cannot find symbol.

all the taglibs are there for portlet2.0 and my taglib URI is below

<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%> this is the one i am using .

there is a workaround by simply saying

RenderRequest renderRequest = (RenderRequest)request.getAttribute(javax.portlet.request) or something like this.
but i would like to know why the above 2 scenarios does not work.

Posted by dula on August 28, 2008 at 09:34 PM IST #

I see that you have posted the same queries in the Sun Forum( http://forums.sun.com/thread.jspa?messageID=10401839 ) and it has been answered. Let me know if you are facing any issues.

Posted by Deepak on August 29, 2008 at 05:38 AM IST #


I am still getting the same Error, do you happen to know if the BUG is Fixed in NetBeans 6.1 or will it be fixed in NetBeans 6.5 ... as per the link below
there seems to be a JSP parser Error or something.


Posted by Samar on August 30, 2008 at 03:24 AM IST #

can you please let me know what's going on with the above issue.


Posted by Samar Aarkotti on September 09, 2008 at 07:21 PM IST #

I am in need of 2 Websphere Portal Developers
Fulltime Roles, NYC
IBM Platform
ORM Frameworks
Please respond to cfagin@cisny.com

Posted by JSR286 Websphere Portal Developers Needed on July 10, 2009 at 03:02 PM IST #

Anybody knows where i can find tld docs for the portlet tag library http://java.sun.com/portlet_2_0? Thanks in advance.

Posted by alexander.a on August 21, 2009 at 12:43 PM IST #

The content of tld file will be different for each vendors. If you are looking for what the tld file should contain, you can get from the spec. The TLD files for OpenPortal Portlet Container can be found at https://portlet-container.dev.java.net/source/browse/portlet-container/trunk/portletcontainer/src/META-INF/

Posted by Deepak on August 21, 2009 at 12:55 PM IST #

Has anyone resolved this issue? I am using Netbeans with Portal Server and Portal Pack.

Not only that, but it doesn't recognize the tld files either. Where do they need to go in the project for Netbeans to
recognize the files? When I deploy the jsp's, it has no errors since Portal resolves it, but with the errors in it not
finding the the tld's, it renders Netbeans ability to recognize classes inoperative. Any thoughts or suggestions would
be greatly appreciated.

Posted by Gary on November 04, 2009 at 02:43 PM IST #

I am using maven . But it is unable to compile the following tag
<%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>

I dont have anything in tld
removed std-tld entry from web.xml

Plz help

Posted by Amit on January 18, 2010 at 12:41 PM IST #

Are you trying to pre-compile the jsp?
The tld corresponding to the taglib will be added to the web.xml when you deploy the portlet.

Posted by Deepak on January 19, 2010 at 02:54 AM IST #

I am using maven too, and in netbeans it underlines in red the taglib line, since I didn't inlcude any libraries for that. Should i include something like a portlettaglib.jar? I have that package in Netbeans portal pack, but I'd like not to be bounded to local jars. Is there a maven repo for that? Thanks

Posted by mox on February 24, 2010 at 06:22 AM IST #

Go and die lar... not helpful at all..

Posted by askhole on April 27, 2011 at 07:12 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed

Deepak Gothe


« August 2016