Jsp:param
Introduction:
1. While performing forward or include we can send parameters to target page for this we have to use <jsp:param>.
2. We can pass the parameter names and values to the forwarded file by using a <jsp: param> tag. We can use multiple <jsp: param> tag inside the <jsp: forward> tag if we have to pass more than one parameter to the target file.
Syntax:
<jsp:param name= “course1” value= “jsp1”/>
Attributes:
This standard action defines the following 2 mandatory attributes:
1. name :The name of the parameter.
2. value : Value of the parameter.
Example:
first.jsp
<h2>This is First JSP</h2> <jsp:include page="/second.jsp"> <jsp:param value="scjp" name="course1"/> <jsp:param value="scwcd" name="course2"/> </jsp:include> |
second.jsp
<%@ page isELIgnored="false" %> <h2> This is second JSP </h2> <h3>course 1: ${param.course1}</h3> <h3>course 2: ${param.course2}</h3> |
Output: http://localhost:8080/Scwcd_jsp/first.jsp
No comments:
Post a Comment