I
iliad
- application type: JSR168 portlet
- version: JSP 1.2, Servlets 2.3
i would like to do the following but i cannot access the ArrayList via
the JSP. could anyone help?
1. use the doView()- method to store an ArrayList in the session
=================================================================
doView(){
....
MySimpleBean my1 = new MySimpleBean();
my1.setMessage("test1");
MySimpleBean my2 = new MySimpleBean();
my2.setMessage("test2");
ArrayList mySimpleBeans = new ArrayList();
mySimpleBeans.add(my1);
mySimpleBeans.add(my2);
request.getPortletSession().setAttribute("jens", mySimpleBeans,
PortletSession.PORTLET_SCOPE);
....
}
2. access this bean from the JSP (this does not work)
=================================================================
<%@ page session="true" contentType="text/html"
import="java.util.*,javax.portlet.*,
com.linde.portal.application.domino.pike.navigation.*" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
<portlet:defineObjects />
<jsp:useBean id="jens"
class="com.linde.portal.application.domino.pike.navigation.MySimpleBean"
scope="session"></jsp:useBean>
<table>
<c:forEach var="mySimpleBean" items="${jens}">
<tr>
<td><cut value="${mySimpleBean.message}"/></td>
</tr>
</c:forEach>
</table>
3. this code works...
=================================================================
....
<%
ArrayList jens2 = null;
try {
PortletSession mySession = renderRequest.getPortletSession();
jens2 = (ArrayList) mySession.getAttribute("jens",
PortletSession.PORTLET_SCOPE);}
catch (Exception e){
e.printStackTrace(System.out);
} %>
<%
if (jens2 != null){
%>
<%= ((MySimpleBean)jens2.get(0)).getMessage() %>
<%} else { %>
<%= "empty" %>
<%} %>
- version: JSP 1.2, Servlets 2.3
i would like to do the following but i cannot access the ArrayList via
the JSP. could anyone help?
1. use the doView()- method to store an ArrayList in the session
=================================================================
doView(){
....
MySimpleBean my1 = new MySimpleBean();
my1.setMessage("test1");
MySimpleBean my2 = new MySimpleBean();
my2.setMessage("test2");
ArrayList mySimpleBeans = new ArrayList();
mySimpleBeans.add(my1);
mySimpleBeans.add(my2);
request.getPortletSession().setAttribute("jens", mySimpleBeans,
PortletSession.PORTLET_SCOPE);
....
}
2. access this bean from the JSP (this does not work)
=================================================================
<%@ page session="true" contentType="text/html"
import="java.util.*,javax.portlet.*,
com.linde.portal.application.domino.pike.navigation.*" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
<portlet:defineObjects />
<jsp:useBean id="jens"
class="com.linde.portal.application.domino.pike.navigation.MySimpleBean"
scope="session"></jsp:useBean>
<table>
<c:forEach var="mySimpleBean" items="${jens}">
<tr>
<td><cut value="${mySimpleBean.message}"/></td>
</tr>
</c:forEach>
</table>
3. this code works...
=================================================================
....
<%
ArrayList jens2 = null;
try {
PortletSession mySession = renderRequest.getPortletSession();
jens2 = (ArrayList) mySession.getAttribute("jens",
PortletSession.PORTLET_SCOPE);}
catch (Exception e){
e.printStackTrace(System.out);
} %>
<%
if (jens2 != null){
%>
<%= ((MySimpleBean)jens2.get(0)).getMessage() %>
<%} else { %>
<%= "empty" %>
<%} %>