0

I am defining one variable in Parent JSP and accessing tag file from that jsp where the same variable is changing based on some conditions.

Here is my code ..

Parent JSP :

<c:set var="replaceParams" value=":${attribute.name}:${value.name}" />
<c:set var="removeURL" value="${fn:replace(queryParams, replaceParams, '')}" /> <!-- Suppose value is A -->
<%@ taglib prefix="cms2" tagdir="/WEB-INF/tags/spine/surgery"%>
<c:forEach items="${attributeDTOList}" var="attribute" varStatus="status">  
   <cms2:attributeSubFeatureRemove attribute="${attribute}" /> 
</c:forEach>
<!-- Print removeURL showing "A". It has to show "AB" --> 

attributeSubFeatureRemove.tag--

   <%@ attribute name="attribute" required="true" type="com.medtronic.b2b.core.dto.HCCB2BClassificationAttributeDTO" %>
   <%@ attribute name="removeURL" required="true" type="java.lang.String" %>
   <c:forEach items="${attribute.subFeatures}" var="subAttribute">
        <c:forEach items="${subAttribute.attributeValues}" var="subValue">
           <c:if test="${ subValue.preSelectionRequired}">
             <c:set var="replaceParams" value=":${subAttribute.name}:${subValue.name}" />
             <c:set var="removeURL" value="${fn:replace(removeURL, replaceParams, '')}" />            
          </c:if>
        </c:forEach> 
     </c:forEach>
     <!-- Now Suppose removeURL value changed to AB-->

In the above code Parent JSP is having variable removeURL which is of String Type. I am sending this removeURL variable inside tag file. Tag file will change the same removeURL variable to hold updated String.

Now If I will try to get removeURL in Parent JSP, it is print the same value as before in parent jsp. Updated calculation value (in tag file) is not reflecting in parent JSP.

I am confuse with scope whether it will make removeURL variable consistent or not. Please help me to get updated value in Parent JSP as well.

Free-Minded
  • 5,322
  • 6
  • 50
  • 93

2 Answers2

0

Please see my response to your other question here: How to pass Object using jsp:include param tag into another jsp

I think that will make your life much easier and render this question no longer relevant. If you agree that the other technique is better, I would close this question.

Community
  • 1
  • 1
alfreema
  • 1,308
  • 14
  • 26
0

You can specify the scope of a variable by using the scope attribute

`<c:set var="removeURL" value="${fn:replace(queryParams, replaceParams, '')}" scope="request" />`

You can also use page, session or application

steven35
  • 3,747
  • 3
  • 34
  • 48