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”%>

<portlet:defineObjects/>


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”%>

<portlet:defineObjects/>

 

Comments:

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

thanks
Sam.

Posted by Samar on August 25, 2008 at 03:32 AM 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.

2)
<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 29, 2008 at 04:34 AM 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 12:38 PM IST #

Yes,

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.

http://www.netbeans.org/issues/show_bug.cgi?id=141287

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

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

thanks

Posted by Samar Aarkotti on September 10, 2008 at 02:21 AM IST #

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

Posted by JSR286 Websphere Portal Developers Needed on July 10, 2009 at 10: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 07: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 07: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 10:43 PM IST #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by deepakg