• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp versus servlets

 
Nidhi Jain
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can anybody tell me the detailed diffrence between jsp and servlets.I only know that after complied jsp will trun into servlets.but that' not a diffrence.

Thanks
 
Girish Solanke
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

As far as my knowledge is concern,

Servlet & JSP are act as servlet itself,

But basic difference between them is
Use JSP when you have more Presentation logic than Bussiness logic
&
Use Servlet when you have more Business logic than Presentation logic



Regards
Girish
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think of JSP as an extension of servlets; specifically designed for formatting a textual response (HTML, etc...).
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Functionally, you could say Servlets and JSPs are the same. They both are compiled and run as Servlets on the JVM. Pretty much anything you can do in a Servlet, you can do in a JSP.

Having said that, JSPs are obviously designed to serve markup to the client, but it HTML, HTML, XML or WML. They are easy to manipulate in a builder tool. Servlets typically defer to a JSP for markup generation.

Servlets are all about the Java. You can write all sorts of control code in a Servlet. A Servlet typically handles an incoming request, and figures out how to handle that incoming request, which usually involves validation, calling on JavaBeans and EJBs, and as I mentioned, deferring to a JSP for markup generation.

JSPs are mostly HTML with a little bit of Java in them. Servlets are largely Java, with the occassional and rare bit of HTML. Someone more clever than me once remarked that "JSPs are just Servlets turned inside out."

I've got a bit more on how Servlets and JSPs fit into MVC on my website. Here's the link:

http://www.technicalfacilitation.com/get.php?link=whatismvc
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic