I'm trying to print a string variable via my jsp file, here is my code:
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.lang.*;"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>why are you not working</title>
<meta charset="utf-8" />
</head>
<body>
<%
String test = "<b><u>bold and underlined</u></b>";
%>
<c:set var="test1" value="<u>underlined</u>" />
<c:set var="test2" value="${test}" />
<c:out value="${test}" escapeXml="false" />
<c:out value="${test1}" escapeXml="false" />
<c:out value="${test2}" escapeXml="false" />
</body>
</html>
output:
Is there a way to print test or test2 using JSTL ? As you can see in the code above I've managed to print the variable test1 but nothing appear on the page for the variables test or test2.
PS: why I want to use JSTL ? Because it offers a way to evaluate html tags and not escape them