• 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
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Article on JSPs

 
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello bear bibeault, i read your this article "The secret Life of JSP".
and one point still not cleared to me is : you wrote in that article:


Since we know that the JSP engine expects to be generating text data (the underlying input/output mechanisms are text-oriented) and that all template text in a JSP including white-space is emitted as part of the document, we can see that using a JSP to emit binary data (or even strictly formatted text data) whose structure would be corrupted by such extraneous characters is a rather foolish thing to try to do.



how it says that use jsp for processing is not good.
and what is exactly mean of this line??


and that all template text in a JSP including white-space is emitted as part of the document.


In servlet data is not part of the document.??

 
Bartender
Posts: 1845
10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"The secret life of JSP" doesn't really discuss why using a JSP for processing is not a good idea.
However the second linked article : The Front Man does. I suggest you go read that one to find the answer to your question.

Here is one reason given:

Not only was the code hard to read, embedded as it was amidst tons of Javascript and HTML markup, it was untestable, unable to be reused, difficult to refactor, and just a plain bear (in a bad way) to deal with.





and what is exactly mean of the line: "that all template text in a JSP including white-space is emitted as part of the document. "



Pretty much what it says.
You include a carriage return in a JSP, it carries that carriage return through to the generated HTML.

Yes, Servlet data is part of the document. The difference in a servlet is that it only outputs what you tell it to via out.println() statements, so you have finer control.
JSP can add extra whitespace - which for the most part when dealing with HTML doesn't matter in the slightest. You should just be aware that it does for those 0.01% of cases where it DOES matter.

 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stefan Evans wrote:which for the most part when dealing with HTML doesn't matter in the slightest. You should just be aware that it does for those 0.01% of cases where it DOES matter.


Indeed. As the article points out, using a JSP to emit binary formats can be disastrous as the extra characters can completely screw up the binary format. Even when dealing with some text formats, such as RTF, where line endings and whitespace matter a great deal, JSP is not the appropriate choice.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for response..


Indeed. As the article points out, using a JSP to emit binary formats can be disastrous as the extra characters can completely screw up the binary format. Even when dealing with some text formats, such as RTF, where line endings and whitespace matter a great deal, JSP is not the appropriate choice.



it gives me my answer...
but can you tell me just any example where line endings and whitespace matter a great deal??
that makes it to me more understandable...

Thank You..
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Already did: RTF.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
seems, i need to have a google search for RTF..
thank you...
 
A feeble attempt to tell you about our stuff that makes us money
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic