JSTL Core url Tag


JSTL Core url Tag

JSTL Core url Tag is use to get Relative path of specified page and JSTL Core url Tag will also help us to get jsessionid in JSP page.

<c:URL> is an alternate of response.encodeURL() of jsp.

Syntax

  1. <c:url value="page_name"/>  

Example

Here i am taking header.jsp page and i will try to get header.jsp page url in JSTL.jsp page.

header.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>javagf</title>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
</head>
<body>
 <c:out value="WWW.JAVAENOTES.COM" />
</body>
</html>

JSTL.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSTL Examples</title>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
</head>
<body>
 <c:url value="/header.jsp"/>
</body>
</html>

Output

/JSTL/header.jsp;jsessionid=F2BF59BF0AAAED651A67BFB32FFC4FBA

Please observe above output we got jsessionid and relative path of header.jsp page.






Full-stack web and mobile app development company Contact Us : Skype: indore.webcoder Email: info@w3sparks.com Sales: +91 8085506229