aspose file tools*
The moose likes JSP and the fly likes Article on JSPs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Article on JSPs" Watch "Article on JSPs" New topic
Author

Article on JSPs

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1001
    
    2
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.??

Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
"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.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1001
    
    2
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

Already did: RTF.
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1001
    
    2
seems, i need to have a google search for RTF..
thank you...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Article on JSPs