Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between jsp and servlets

 
kavitha vasu
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • 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
 
arulk pillai
Author
Ranch Hand
Posts: 3388
  • Mark post as helpful
  • send pies
  • 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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
sanjeev mehra
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • 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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic