File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes what's the different between JSP and servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "what Watch "what New topic
Author

what's the different between JSP and servlet

ellen berry
Ranch Hand

Joined: Jun 10, 2001
Posts: 31
Hi, guys:
right now I am learning JSP and Java Servlet. but I have some confuse that JSP and servlet can do the same things? or they do different function in some sepcific areas. what's the different?

ellen
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
JSPs are used like HTML markup using special JSP tags, but generating dynamic (versus static) content.
Servlets extend the functionality of a server and are used to prepare javabeans for JSPs to use. Servlets are the controller and JSPs are the view.
That's a very short explanation but the best way is to read books and/or on line articles on the subject and then practice with an app server which you can easily install in your PC.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Dmitriy Pavlyuk
Ranch Hand

Joined: Mar 25, 2001
Posts: 33
The easy difference is that
using JSP you insert calls the class into markup (html tag) but
using Servlet you insert tag into class code.
Using JSP you divide the presentation and bisness logic. Servers which allow JSP automatically create servlets from jsp pages.
Kai Middleton
Greenhorn

Joined: Jul 27, 2001
Posts: 12
Here's an answer a fellow programmer of mine had:
Well JSP actually turns into a servlet the first time it is accessed. I discussed this recently with my colleagues and basically it seems cleaner to use JSP with tag libraries to generate XML than to do stuff with servlets.
Anyway you slice it, it is still compiled Java anyway. But JSP allows you to mix and match content, images, style sheets in the same directory with the JSP so you can easily refer to it. And it seems easier for people to figure out where to go to debug when they can just see a URL that matches the path in their directory.
Another small benefit is that when you change a JSP you don't have to cycle the service it automatically gets recompiled and loaded in, so this is nice.
JSP tag libraries give you a nice way to build and reuse code modules as well. There are other niceties that JSP's give you but the above features are some of the more important things.
There is not much difference between using JSP and servlets other than the above but these small things make it a little nicer than just servlets.

[This message has been edited by Kai Middleton (edited August 01, 2001).]


<I>Kai M.</I>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what's the different between JSP and servlet