Raghavan said:
Servlets and JSP are both the technologies used in the J2EE Web
application. An one line difference would be, "In Servlets you can
embed html code with java so as to display something in the browser; in
JSP, you embed java code along with html code so as to have your
decision making with logics".
Please, no!
This is almost entirely backwards (it's a popular technique, but it's
rubbish code)
Try this:
"In Servlets you write Java code to implement logical decision making.
You can possibly generate HTML code here, but it's tedious to author it
and not recommended.
In JSP, you write HTML with Java embedded it, so as to have easy HTML
authoring and also access to the results of Java code. Good JSP has a
minimum of either Java code or control logic directly embedded in it.
Keeping JSPs free of Java can be assisted by using Tag Libraries.
Keeping control logic out of JSP can be done by keeping it in separate
Servlets and using an MVC pattern."
But then writing html code in java is having much overheads
Why? Do you understand how JSP is compiled before execution?
The later part of your post is broadly correct, but you'd already
confused the poor reader.