Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Differences between JSP and Servlets

Status
Not open for further replies.

SDM

IS-IT--Management
Jan 10, 2001
14
AU
Hi we're in the process of choosing an architecture for our web platform and was wondering if anyone out there could tell me what the difference is between JSPs and Servlets and what are the pros and cons of each?

Any help would be greatly appreciated.

Cheers.
 
JSP and Servlets are closely related.

Servlets came first, and are basically a Java program that resides on your web server that you can send and receive http requests. An http request can include parameters (which is how a form works) which in the past would have been handled by a CGI program. So, you can request that a servlet runs with a url and pass parameters, the servlet does some processing then outputs an html page. This is the 'con', when programming a servlet you will end up writing out loads of html lines with System.out.println(&quot;<P>a line of html</P>&quot;); statements.

JSP is a way of reducing the amount of println's that you have to do. You write a normal html page script then embed a bit of Java in it. When this page is requested from the web server for the first time it will actually compile itself into a servlet, writing the println's for you.

A wise way to use JSPs is the embed Java Beans within the html. This means that non-Java html coders code utilise Java code quickly and easily. If you were designing lots of web sites this would be very useful.

Servlets and JSP work happily together as they are both just parts of J2EE.

In general, the J2EE environment is superior to that of ASP in the way that it uses web server memory. It is also more secure and stable. My home ----> My company ->
 
In addition, JSP and servlets are platform independent ( they can run on any operating system and web server that supports them--most do) whereas ASP's are neatly tied to M$ and IIS.
 
In simple terms, this is how I would define servlets and Jsp.

Servlets - HTML in java
Jsp - java in HTML
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top