Comments in Jsp

Source: Internet
Author: User

The JSTL tag is used today. When redirecting a tag, I encountered a very bad problem, that is, when I test the tag, I want to test other content, because it is redirected (the browser address will change), it will certainly affect my subsequent tests, so I want to comment out this line of code:

Then I tested the other content, but the problem was that every time I refresh the browser, I still redirected it. I wondered, isn't this sentence a comment? Why did I still execute the statement, and then I deleted the sentence. At this time, I knew whether the comment was useful, And then I checked the information online, this annotation is useless for Jsp. It is the original html/xml annotation and should be used.<% -- -- %>This annotation is enough, and then I think about it again. The original notes in Java: // and/**/can also be commented out as follows:<% //-- -- %>,What is the difference between this and the above two types? At this time, the execution process of jsp may be required. Here we will simply say that every jsp page will be translated into servlet by the jsp Engine. java, the specific content can be found in the Project in the work folder under the tomcat directory, so the last comment is a thorough comment, because it is in servlet. java is commented out, and the previous two annotations are in servlet. java code is not commented out. below is the servlet. java code snippet:

Note the following with <% //... %>:

Out. write ("--> \ r \ n ");
Out. write ("

\ R \ n ");
Out. write ("\ r \ n ");
Out. write (" \ R \ n ");
Out. write ("");
//

Here we can see that this sentence is directly commented out, namely:Content in Jsp <%... %> will be translated into servlet. java intact

Annotated with <% ---- %>:

Out. write ("--> \ r \ n ");
Out. write ("

\ R \ n ");
Out. write ("\ r \ n ");
Out. write (" \ R \ n ");
Out. write ("");

Use Note:

Out. write ("--> \ r \ n ");
Out. write ("

\ R \ n ");
Out. write ("\ r \ n ");
Out. write (" \ R \ n ");
Out. write (" The comment has no effect!


Summary:

1. First comment:

This is the original HTML/XML comment, which will be honestly sent to the client. If there is anything you can't see, use it.


2. The second annotation:

<% -- Comment content -- %>

The content <%> is written to the JSP application server and will not be sent to the client. The compiler ignores it, and html does not meet with it, and the app server is no longer involved. This annotation seems redundant, and I don't know what to do with another such annotation.


3. Comment 3:

<%

// When the line comment

/**

Multi-line comment

*/

%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.