<%!
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 ?
just but the <%=str%> in double quotes this should work , i hope this is an answer to your question.
To pass parameters to a jsp jstl:
Just put it in
value
directly.Or use JSTL
<c:set>
to set it and EL${}
to get it.And if your included page is a jsp, then you can use it as
${param.type1}
Request parameters can be passed by using
<jsp: param>
One can pass the parameter names and values to the forwarded file by using a
<jsp: param>
tagSample e.g :
HTML :
<jsp:param>
tag is used to pass the name and values to the targeted file. These parameters will be retrieved by the targeted file by usingrequest.getParameter()
method. In this way one can pass and retrieve the parameters.Using
request.setAttribute()
you can pass the Java variable to the JSP.