| Author |
Servlets Vs JSP
|
nalini peddareddy
Greenhorn
Joined: Jul 18, 2005
Posts: 16
|
|
Hi, I know every JSP is translated into Servlet and JSP could better act as a presentation layer. A JSP can do all that a Sevlet can do. Then what is the main difference between both of them? Servlets are preferred to be used for business logic. Why not JSP's when JSP also is finally a servlet? Could anyone please clear my doubt? Regards, P.N.Reddy
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
Because if you'll use an MVC layout, you'll have to keep your presentation separated from your logic (you've said you already know it)
Why not JSP's when JSP also is finally a servlet?
There are so much things you can do nowadays This is good and bad. Why ? Because you can also do a lot of crap. You may use a JSP to act as a servlet. After all, there's also a tag in web.xml for it. But, should you really use it ?
|
[My Blog]
All roads lead to JavaRanch
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
|
Moreover, you can search the same forum or a servlet forum in order to get more results.
|
 |
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
|
|
A JSP isn't really just "a servlet". Think about it this way - when you write a JSP page, you aren't really writing a servlet. It's more like a template - you provides a mix of HTML telling how the page looks, along with tags to let the page "hook into" other parts of your web application. Later the application server comes along and uses this template that you wrote to produce a servlet that is specialized for displaying the HTML page you wrote in the template.
|
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1008
|
|
A JSP is an HTML page with bits of java embedded in it. If you had to write that as a servlet manually, you would have a heck of a lot of out.println() statements, and it would be a nightmare to maintain. Thats basically the difference. Servlets were "invented" first. JSPs came about because people wanted an easier way to write servlets that were output only.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
|
|
Just because JSPs are implemented using servlets does not mean that they are interchangable. As Nathan pointed out, JSP is a templating technology for delivering text-based output to browsers. There is no "versus" -- JSP and servlets are complimentary technologies, not competing. A well-written web application uses both to their best advantages.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: Servlets Vs JSP
|
|
|