Using jsp: param / c: param in a portlet environment

I am trying to enable JSP pages with jsp:paramin a portlet environment (using the Pluto portlet container ).

eg,

<jsp:include page="test.jsp">
   <jsp:param name="foo" value="bar"/>
</jsp:include>

and in test.jsp,

<c:out value="${foo}"/> or <%= request.getParameter("foo") %>

The output is always zero, and I also tried using tags c, but got the same result.

<c:import url="test.jsp">
   <c:param name="foo" value="bar"/>
</c:import>

I was browsing the network and many people faced the same problem, except that there was no solution for it.

Is this a limitation or is there another way to do this?

+3
source share
2 answers

Servlet, , - , , , . , , , , .

<jsp:param> , :

<c:set var="foo" value="bar" scope="request"/>
<jsp:include page="test.jsp"/>

test.jsp:

<c:out value="${requestScope.foo}"/>

, , :

<c:out value="${foo}"/>

params, .

+2

. Portlet renderRequest ( jsp ). RenderRequest, JSP ( jsp:include). API renderRequest. :

MyPortlet:

public void doView(RenderRequest request, RenderResponse response) {
  request.setAttribute("myBean", new MyBean());
  getPortletContext().getRequestDispatcher("myMainJSP.jsp").include(request, response);
}

myMainJSP.jsp:

<jsp:include page="header.jsp"/>

header.jsp:

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<% page import="sample.MyBean" %>
<portlet:defineObjects/>
<%
  MyBean myBean = (MyBean)renderRequest.getAttribute("myBean");
%>
... html code...
+1

All Articles