Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Difference between jsp and servlets

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I can undertstand that the difference between jsp and servlets is

in JSP, java code is embedded within html

in servlet, html is embedded within java code


Apart from this point of view, can one explain what are the other differences between jsp and servlets


Thanks & Regards
Kavitha
 
Author
Posts: 3450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, That is the main difference and to elaborate on that it is
quite cumbersome to have html code in java with all the out.println and escape sequences. So to overcome this JSPs were brough where Tags are embedded (including Java code directly is not the best practice) inside html for dynamic content.


The another difference is that: JSPs have a translation phase where the JSPs are eventually converted to a servlet by the JSPEngine within the Web Container.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

in JSP, java code is embedded within html. in servlet, html is embedded within java code


Mmmh, that could be one way to see it. But in fact, JSP's purpose is not to embed java code, neither is servlets's purpose to output html. I think you didn't make your way up to the Design Patterns yet (there are some at the exam). One of them is the MVC pattern. Check this FAQ.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
role of servlet is different from role of jsp in application.
-servlet act as <b>controller</b>
-servlet is <b>oo base</b>
-jsp is used for <b>view</b>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic