Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass java variable in jsp:param

Tags:

 <%!  
    String str = "prerna";  
  %>  

 <jsp:include page="index.html">
      <jsp:param name="type1" value=<%=str%> >
      </jsp:param>  
 </jsp:include>

I want to pass a java variable in the param tag,but i am not sure how to do it.

I also want to access it in index.html.
Can anyone suggest me the way to do it ?

like image 937
Deep Avatar asked Mar 26 '11 17:03

Deep


1 Answers

Just put it in value directly.

<jsp:include page="index.html">
    <jsp:param name="type1" value="prerna" />
</jsp:include>

Or use JSTL <c:set> to set it and EL ${} to get it.

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
...
<c:set var="type1" value="prerna" />
...
<jsp:include page="index.html">
    <jsp:param name="type1" value="${type1}" />
</jsp:include>

And if your included page is a jsp, then you can use it as ${param.type1}

like image 85
BalusC Avatar answered Sep 17 '22 21:09

BalusC