In this example you’ll see how to add comments in JSP page / JSP scriptlets. To add comments we can use either the JSP comment style or HTML comment style. The different between this is that the HTML comment will be sent or included in the webpage while the JSP comment is not included in the webpage.
The JSP comment style start with the <%--
and end with the --%>
. To create an HTML comment style we can use the <!--
and closed by the -->
. Beside this two comment styles you can still use the comment block that we use in our Java code in the JSP scriptlets.
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Commenting JSP Page</title>
</head>
<body>
<%--The JSP snippet below is used to print the current date--%>
<%
Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd/MM/yyyy");
%>
<%= "Today is: " + formatter.format(date) %>
</body>
</html>
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024
Nice post, thanks keep posting.
Great information, I get so much information from post and replies. I request you to please write some informative post on java Training.
Thanks for the informative article. Keep sharing the quality content. Visit us Java Classes in Pune