2

I am trying to pass a parameter from one jsp file to another using

From Index.jsp

<jsp:include page="footer.jsp">
   <jsp:param name="main" value="true"/>
</jsp:include>

And then Accessing param main in footer.jsp using

  <h1>The value : ${param.main}</h1>
  <c:choose>
    <c:when test="${param.main=='true'}">
      something
    </c:when>

however, param.main still remains null in footer.jsp.

Our code uses HIPPO CMS. Is there a way I can send a parameter from one jsp to another in HIPPO CMS. I tried searching but i could not find anything relavant to HIPPO CMS.

cadrell0
  • 17,109
  • 5
  • 51
  • 69

3 Answers3

2

We used taglibs for this. It worked.

Create a tag file footer.tag (This file will resemble footer.jsp)

Then in index.jsp include the tag file using

<customTag:footer main="true"/>

(Custom Tag denotes the folder in which your footer.tag is being kept)

This will include the footer tag in the index.jsp and parameters can be passed as mentioned above.

A sample of the footer tag :

<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://www.hippoecm.org/jsp/hst/core" prefix='hst'%>

<%@ attribute name="main" required="false"%>

<p>The value of main is ${main}</p>
0

I managed to fix this issue using following code:

<c:set var="name" value="${value}" scope="request" />
<jsp:include page="page.jsp" />
kolobok
  • 3,835
  • 3
  • 38
  • 54
0

Hippo wraps HttpServletRequest with it's own request and adds a prefix for attribute name to access attribute with same name in different components (or browser windows). But all of this can not stop you for using pure HttpServlet.setAttribute - just get RequestContext from HstRequest and then get HttpServletRequest:

HstRequest hstRequest = ...
hstRequest.getRequestContext().getServletRequest().setAttribute("attributeName", new Object());
Cherry
  • 31,309
  • 66
  • 224
  • 364