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

Servlets and JSP  RSS feed

 
Rahul Shyam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recently I was asked the following question in an interview.


Tell me one thing that can be done from a servlet but not from a JSP and one thing that can be done from a JSP but not from a Servlet.


Can someone please tell me what would be the answer to this question.
Thanks
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since most JSP implementations work by converting JSP files into servlets, I don't think there is anything JSPs can do that servlets can't.
As to the reverse, have a look at the JSP spec to see what Java language features you can't use in a JSP; from there you can construct a servlet that relies on that feature.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree withJSPs, I can't think of anything they can't do from Servlets. One thing a Servlet can't do is the stuff related to tag libraries e.g some tag libraries allow you to capture the output and cache it locally.

Some people may tell you that JSPs can't output binary data, and while this isn't always easy to do it is certainly possible.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!