wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes How to escape the html comments without encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to escape the html comments without encoding" Watch "How to escape the html comments without encoding" New topic
Author

How to escape the html comments without encoding

Muralitharan Kathirvelu
Greenhorn

Joined: Aug 18, 2007
Posts: 9
Hi all,

I am having the file which contains the data as
<!-- sample data --> ABC is commented using HTML Comments -->
<html>
<body>
HTML Data
</body>
</html>

The whole file was formed by myself using java. For my project purpose am commenting some data's(dynamic data) in that file.

After the open comment am having the two close comments.
Second one is the actual close comment first is the data.
At the time of store and executing the file in browser it shows the ABC is commented using HTML comments --> after that only executing the html tags.

I want the solution to escape all the html comments without encoding (> or any numbers) except the last one in by file.

At the time of seeing the view source of my file it has to show the exact copy what i typed previous.

Thanks in advance...
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1180
You might consider handling it in the JSP or Java code. You have three levels of comments available to you -

  • HTML Comments
  • JSP Comments
  • Java programming language comments



  • William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
    Muralitharan Kathirvelu
    Greenhorn

    Joined: Aug 18, 2007
    Posts: 9
    I want to handle html comments in my jsp page
    Eric Pascarello
    author
    Rancher

    Joined: Nov 08, 2001
    Posts: 15376
        
        6
    If you read the specifications it should say something like this:

    An HTML comment begins with '<!--', ends with '-->' and does not contain '--' and/or '>' anywhere inside the comment opening and closing tags.

    The parser will see the first one and close the comment, that is how it works. The only way you get around it is to escpae it or do not output it in the first place.

    Eric
    Dan Drillich
    Ranch Hand

    Joined: Jul 09, 2001
    Posts: 1180
    Originally posted by Muralitharan Kathirvelu:
    I want to handle html comments in my jsp page


    Right, if you use JSP comments in your jsp page, the comments won't reach the html page.
     
     
    subject: How to escape the html comments without encoding