The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

"better" is a relative term...

Posted by Jeff Kinsey on September 04, 2000 at 12:33 PM

It depends on what you are trying to do as to which is better in a given situation. A JSP is Sun's attempt at de-coupling content (HTML) from code. A servlet generally is a class that has �HTML� embedded as Strings that are output to the HttpServletResponse�s PrintWriter. The problem with this approach is that every time you want to change your HTML, you have to make a coding change.

Think of a JSP as a Servlet �inside-out�. In other words, a Servlet is a class with HTML within it. A JSP on the other hand is HTML with Java scriptlets within it.

I prefer to use a combination of Servlets and JSPs. I use the Servlet as a controller to speak to the backend server-side, and I use JSP�s to format and display content back to the browser.

Enough for now. There are plenty of good books out on JSPs as well as some good websites. I suggest starting here: http://java.sun.com/products/jsp/index.html

> Dear Friends,
> I just want to know which one is better JSP or Java Servlets as both are Server Side Scripting And out of these two which will emerge in front.
> Thanking you
> Ankush.Khona






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us