This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jsp and Servlet

 
kiran babu ssr babu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question is, what a that which a servlet can do which cannot be done by jsp.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer your question directly, there is nothing that a servlet can do that a JSP can't. JSPs get compiled into servlets by the container.

A servlet is better laid out for handling control flow and interacting with back end objects. If you need to stream binary data you're better off using a servlet.

JSPs are best suited to for formatting your data and mixing it with HTML after all the heavy work has been done in a servlet.

If I had to, I could pound in nails with the back of a wrench but I'd prefer to use a hammer.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer your question directly, there is nothing that a servlet can do that a JSP can't. JSPs get compiled into servlets by the container.

In order to make a JSP stream binary content such as an image you have to write something that doesn't really look like JSP - or do you have some magic method?
Bill
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:

In order to make a JSP stream binary content such as an image you have to write something that doesn't really look like JSP - or do you have some magic method?
Bill


No, I do not have a magic method and, Yes I agree, you would have to write an extremely ugly JSP.
This is why I said:
If you need to stream binary data you're better off using a servlet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic