简体   繁体   中英

What is the easiest way to hide HTML code from users eye?

I am currently working with JSP pages and would like to know what would be the easiest way to comment HTML/Java code from being able to see it when you open source on the web. As for now, I was used to use

<%-- html/Java code --%>

However, later on it screw up all highlighting of JSP file. Maybe there is another way of commenting multiple lines without possibility to see them in HTML source on web.

Look:

<%-- Comment --%>  - commenting out html

<% /*java code*/ %>  - commenting out java code  

<!-- comment --> - html comment, ignored by the browser

I would like to quote Oracle on this one: Code Convention

Please note the following (excerpt from the link):

  1. JSP comments (also called server-side comments) are visible only on the server side (that is, not propagated to the client side). Pure JSP comments are preferred over JSP comments with scripting language comments, as the former is less dependent on the underlying scripting language, and will be easier to evolve into JSP 2.0-style pages.

Examples:

<% /** ... */ %>
<% /* ... */ %>
<% //... %>
<% //... %>
  • Client-side comments can be used to annotate the responses sent to the client with additional information about the responses. They should not contain information about the behavior and internal structure of the server application or the code to generate the responses.

Let's note that these comments:

<!-- ... -->

ignore all elements except @import statements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM