Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Commented tag still Executed!

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My welcome.jsp has these lines:

<html><head></head><body>
forward to anther page
<!-- <jsp:forward page="/Lookup.do"/> -->
</body>
</html>

I commented out the forward but the page is still got forwarded! Instead, I need to use alternate comment syntax:

<html><head></head><body>
forward to anther page
<%-- <jsp:forward page="/Lookup.do"/> --%>
</body>
</html>

Wrong is wrong with it? Is the <jsp:forward> preprocessed before the comment? I was using tomcat-5.0.29 during the test.
 
Junilu Lacar
Bartender
Pie
Posts: 8875
81
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use JSP comments, i.e., <%-- --%> instead of HTML comments.

Edit: Of course, you already realized that. The reason for this is that JSP translator does not recognize HTML comments; it's just text that it sees needs to be included in the response. Regarding your question about "pre-processing", the answer would be yes because a JSP is translated into a Servlet.

The text in your JSP:

<html><head></head><body>
forward to anther page
<!-- <jsp:forward page="/Lookup.do"/> -->
</body>
</html>

would be translated into code that would essentially function like this:

out.println("<html><head></head><body>");
out.println("forward to anther page");
out.println("<!-- ");
jspForward("/Lookup.do");
out.println("-->");
out.println("</body>");
out.println("</html>");


whereas this

<html><head></head><body>
forward to anther page
<%-- <jsp:forward page="/Lookup.do"/> --%>
</body>
</html>

would be translated as

out.println("<html><head></head><body>");
out.println("forward to anther page");
// Comment: <jsp:forward page="/Lookup.do"/>
out.println("</body>");
out.println("</html>");
[ May 05, 2005: Message edited by: Junilu Lacar ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic