Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

the major difference  RSS feed

 
Soman Singh
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a simple doubt and tried to know the answer but in vain.
What is the major difference between a Servlet n Jsp.
few Things I know are:
Jsp are easy to learn and handle.
Jsp's gets compiled to servlets.
Html can be generated from both.
jsp's gets compiled to servelts behind the scene.
I find most things similar than difference.
The overall issuse is jsp's can do nothing different which servlets
can't.
So what is that jsp can do n servlets can't or vice versa.
Thanks in advance.
Regards,
Soman Singh
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At its best, a JSP page looks like HTML with a little bit of script sprinkled in. When the JSP is "compiled" into a servlet, the HTML is put into into response.write statements, and the script is left in place to be executable code. The script can be in a couple forms: normal Java or "taglibs" that define special tags. People in my company talk about having zero Java in JSP pages, both to isolate the business logic from the HTML and to allow HTML experts with no Java skills to author pages.
Servlets are pure Java. They can emit HTML by writing strings of HTML to the response stream. But! The same folks who like no Java in JSPs like no HTML in servlets. Again, it helps clarify the roles of the various moving parts and the developers, too.
A neat approach is to have a single servlet in an application. All browser pages get or post to the servlet, which figures out what page and action are in the request, calls plain old java objects to do the appropriate business function, and transfers to a JSP page to format the HTML response.
In short, the servlet controls the flow of operation in a generic way, and the JSP generates the HTML.
Hope that helped!
[ September 08, 2003: Message edited by: Stan James ]
 
Gayathri Prasad
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
To demark the roles of designer and developers clearly Sun came up with JSP and JSP never forces a designer to become developer or vice versa.
Gaya3
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In servlet u can provide support for other protocols also by extending GenericServlet. This is not possible in JSP
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!