• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to escape the html comments without encoding

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I want to handle html comments in my jsp page
     
    author
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    I want my playground back. Here, I'll give you this tiny ad for it:
    We need your help - Coderanch server fundraiser
    https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
    reply
      Bookmark Topic Watch Topic
    • New Topic