faqts : Computers : Programming : Languages : Java : JSP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

617 of 931 people (66%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

What is are the differences between Java Server Pages and Java Servlets?
What are the Advantages of JSP over Sevlets and Servlets over JSP ?

May 10th, 2003 22:27
Chad Woolley, Ben Young, Pranav Dave,


Java Server Pages (JSP) is basically Sun's answer to Microsoft's Active 
Server Pages (ASP).  They work in very similar ways.  ASP allows for 
VBScript, JScript, or PerlScript code to be placed in between sections 
of HTML.  JSP does the exact same thing only using Java as the language 
of choice.  Both ASP and JSP combine the design (HTML) and the code 
(ASP 
or JSP) in the same file.
Java Servlets are a Java equivalent of a CGI script.  Like CGI it can 
generate HTML, but it does not allow for HTML to live in "raw" form 
within the program.  Servlets can be used to process a set of 
instructions and then return the values that were created by the 
Servlet.
JSP also supports "Tag Libraries"  These are simple tags that you embed 
in your JSP, which execute java code that is stored in a separate 
class.  This allows you to keep your keep complex page logic 
encapsulated in separate classes, while keeping your JSP pages "clean", 
and free of java code.  By doing this, you keep the page design in the 
JSP, and the page logic elsewhere.  This makes it easier to develop and 
maintain your pages.
In addition to writing your own tag libraries, you can also obtain free 
open-source tag libraries to perform various functions.