All web developers know that they can add comments to their HTML by use of the <!– –> tag. This causes the contents to not be rendered to the viewer but still displayed in the source of the page. This method of commenting can still be done in JSP but in addition there is the<%– –> tag. This comment does not get displayed in the final page source and is only visible when looking at the un-rendered .jsp page. This tag comes in handy to comment the logic in your JSP pages
Oct
01
Sep
30
Often in JSP we find ourselves creating links to other pages within our web application. The below code allows us to easily get the web application context path from within a JSP file.
${pageContext.request.contextPath}Utilizing JSTL we could also set this value to a variable so that we have a short hand method for getting the context path.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="cp" scope="session"
value="${pageContext.request.contextPath}" />This enables you to use ${cp} to output the context path.