aspose file tools*
The moose likes Servlets and the fly likes Why JSP why not Directly Servlet!.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why JSP why not Directly Servlet!...." Watch "Why JSP why not Directly Servlet!...." New topic
Author

Why JSP why not Directly Servlet!....

Bidyut Padhi
Ranch Hand

Joined: Sep 07, 2000
Posts: 121
Hi friends
Why we will use JSP and not servlet.Because JSP pages are again compiled into servlet and produces the Out put.
Why I will follow this indirect process in which scenario.
What are advantages in JSP over servlet (Regarding performance)?
regards
Bidyut
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
There is essentially no performance difference between JSP and servlets, except the first time a JSP is referenced, when it is compiled to a servlet. After that there is only a tiny overhead in dispatching a JSP, as it checks whether it has changed since the last recompile.
JSPs are best used when a synamic page has almost all static text, with a few small dynamic parts.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

JSPs are a way to rapidly develop web pages, being the default web content. Hence the content type is implicitly set as text/html for you.
Servlets can return any content type and are not limitted to text based content. For example a servlet could return a dynamic image based on the input params.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4339
    
    2

JSP's can help seperate the presentation from the logic by using beans. With servlets you will have long println statements to serve up the response. However I used servlets mostly any way. I used 1 JSP because it was all html, it only need one parameter passed to it to be included in the output. With servlets you have to shut down the server in order to change a servlet code, not so with JSP.


SCJP
Visit my download page
Alok Pota
Ranch Hand

Joined: Mar 07, 2001
Posts: 185
I feel in general JSPs are good if your static content is more than your dynamic content. If you find yourself writing more HTML then processing logic for a given page then consider converting your servlet to a JSP. I like servlets because they easily lend themselves to OOP and offer better control.
Regarding performance, I think I read somewhere that the JspWriter was slightly more optimized compared to the servlet PrintWriter and hence *could* be faster.

A crude comparison: JSP ~driving with automatic transmission, Servlet ~ driving with a stick-shift. The later gives better control. The former is easier.
 
 
subject: Why JSP why not Directly Servlet!....
 
Similar Threads
Servlets and JSP
why don't we use main() in Servlet,Jsp?
How to store/retrieve Image file through JSP
servlet is used as controller
JSP to Servlet pasing values