• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP and Servlet

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Difference between Servlets and JSP?
Could any one make me clear about the difference.
thanks in advance.
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sure there are many difference between the two. They are equal in function. Servlet is easy to read, jsp is more effcient.
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A fairly glib explanation is as follows:
Servlets are Java Classes that generate HTML (or other output)
JSPs are HTML-like files that generate Java Classes.

IMHO - JSP's are better for generating the 'View' tier of the architecture as they provide a better separation between the presentation and the business logic.
Servlets are usful for other purposes such as acting as the 'controller' for incoming requests i.e. delgating the processing and then forwarding the request to the next appropriate JSP or for handling requests for binary content such as documents or images.
Hope this helps
Andy Bowes
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the information!
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One additional comment: the text vs. binary distinction, when deciding on servlets or JSPs for presentation, is not always right-on. There are lots of cases where you'll want to use a servlet to generate text, if it's not in a language in the style of XML, HTML, or WML.
JSPs tend to assume that you're using a format that involves tagged text with tags like <this>, and that your file format is immune to added whitespace, including newlines. If that's not the case, then although it is possible to use JSPs to produce the output, the result will look foreign and be difficult to maintain. In those cases, it's probably better to use a servlet to generate the content.
This can sometimes even become an issue for HTML <pre> tag sections, where whitespace and newlines become suddenly significant. Preformatted sections in HTML are often best written as JSP standard include actions that include the output of a servlet.
 
brevity is the soul of wit - shakepeare. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic