This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to escape the html comments without encoding

 
Muralitharan Kathirvelu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


  •  
    Muralitharan Kathirvelu
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I want to handle html comments in my jsp page
     
    Eric Pascarello
    author
    Rancher
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 1183
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic