I want to use %> literal in JSP page. But it is throwing error. How to escape this syntax in JSP?

JSPJava 8Object Oriented ProgrammingProgramming

You can escape it using backslash character. Replace %> with %/>. Following example showcases the same.

<html>
   <head>
      <title>A Comment Test</title>
   </head>
   <body>
      <h2>Syntax: <\%= (new java.util.Date()).toLocaleString() %\></h2>
      <p>Today's date: <%= (new java.util.Date()).toLocaleString()%></p>
   </body>
</html>
raja
Published on 20-Mar-2019 10:43:01
Advertisements