ricky
ricky

Reputation: 291

How to comment in jspx page

How to comment the code in jspx page? I have tried several methods,

<!--  -->
<%-- -->

but it doesn't not work!

So I have to:

<c:if test="${false}">code</c:if>,

it is really urgly, Is there any other ways? Any help is appreciated!

Upvotes: 4

Views: 6226

Answers (5)

To&#241;o
To&#241;o

Reputation: 3

There are 2 kinds of comments: JSP comments and HTML comments.

  • JSP commet: <%-- comment text --%>

  • HTML/XML comment: <!-- comment -->

JSP comments are not exported to HTML and are ignored by the JSP Engine.

HTML comments are exported to HTML because they are valid HTML tags.

Upvotes: 0

iro&#239;d
iro&#239;d

Reputation: 41

JSP.1.5.2 Comments in JSP Documents

Comments in JSP documents use the XML syntax... The body of the content is ignored completely. [3]

CDATA sections may occur anywhere character data may occur; they are used to escape blocks of text containing characters which would otherwise be recognized as markup. [4]

  1. java.sun.com/products/jsp/syntax/2.0/syntaxref203.html#1004313
  2. java.net/jira/browse/JSP_SPEC_PUBLIC-105
  3. http://jsp.java.net/spec/jsp-2_1-fr-spec.pdf
  4. http://www.w3.org/TR/REC-xml/#sec-cdata-sect

    <![CDATA[<!-- comment -->]]>

Upvotes: 4

himanshu
himanshu

Reputation: 2205

Just use <!-- comment --> for comments. JSPX file uses XML syntax so that's the reason XML style comment work here.

Also read article Creating a JSP Document for understanding the difference between JSP standard syntax and XML syntax

Upvotes: 3

ZZ Coder
ZZ Coder

Reputation: 75496

Have you tried XML IGNORE?

<![IGNORE[
  <!-- commented out XML -->
]]>

Change IGNORE to INCLUDE when you want it back.

Upvotes: 0

Tendayi Mawushe
Tendayi Mawushe

Reputation: 26128

You were close with one of your attempts, JSP comments look like below:

<%-- some commented out stuff --%>

Upvotes: 0

Related Questions