<c:param> Tag
The <c:param> tag is used to specify parameters within the <c:url> tag, and it is related to URL encoding.
Inside the <c:param> tag, the name
attribute indicates the name of the parameter, and the value
attribute indicates the value of the parameter.
Syntax
<c:param name="<string>" value="<string>"/>
Attributes
The <c:param> tag has the following attributes:
Attribute | Description | Required | Default Value |
---|---|---|---|
name | The name of the parameter to be set in the URL | Yes | None |
value | The value of the parameter | No | Body |
Example
To pass parameters to the <c:param> tag, you need to first create a URL using the <c:url> tag:
Example
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>c:forTokens Tag Example</title>
</head>
<body>
<h1><c:param> Example</h1>
<c:url var="myURL" value="main.jsp">
<c:param name="name" value="tutorialpro"/>
<c:param name="url" value="www.tutorialpro.org"/>
</c:url>
<a href="/<c:out value="${myURL}"/>">
Use <c:param> to send two parameters to the specified URL.</a>
</body>
</html>
When accessing the above page through a browser and viewing the source code, it displays as follows: