Intro to JSP
 
SEARCH: webmonkey  the web

 
Java
-------------------------
Print
this article for free. 
-------------------------

Pages:
1  Intro to JSP
2 JSP versus ASP
3 JSP Syntax
4 JSP Browser Detection
5 Digging Deeper

Intro to JSP
by David Markley 31 May 2001

David Markley [an error occurred while processing this directive]is a software engineering manager at Terra Lycos. He writes games on the side and is most known for Hextris. He hopes one day to live in a Hobbit hole ("They're environmentally friendly, don't you know...").

Page 1

Choosing a server-side language used to be easy. Way back when, CGI was pretty much the only scripting option out there. Intrepid developers could write their own server extensions, but few were up to the challenge, and the gap between these two options (inefficient CGI scripts and extremely complex server extension development) was huge.

Microsoft tried to fill this hole with Active Server Pages (ASP), which allow developers to use simple scripting to access the server and its extensions. But while ASP gives you an efficient way to return dynamic content, it essentially limits you to Microsoft platforms, and even the simplest of scripting mistakes can cause the server to crash or hang, effectively bringing down your website.

Apparently in response to ASP, Sun Microsystems gave the world JavaServer Pages (JSP) technology, which is based entirely upon Sun's popular Java programming language and gives developers the advantages of developing in Java in a more relaxed, script-like environment. Behind the scenes, JSP pages are dynamically assembled into Servlets, which are simply Java classes. This means JSP supports the same modularity, reusability, platform-independence, and access to Java APIs that Java programming supports.

Thanks to its foundation in Java and its use of Java threads to handle incoming requests, JSP is a great deal more efficient than many other scripting languages, such as CGI. Its threading model and error handling also help prevent server hangs and crashes. And when the underlying Java Virtual Machine (JVM) makes use of Just In Time (JIT) compilation, the performance of well-written JSP can approach that of C++.

JSP also bests ASP by supporting the definition of tags that abstract functionality within a page, so tags can be defined in a tag library and then used within any JSP page. This makes for a better separation of page content from its code, which is one of Web development's prime directives. The less code scattered throughout the pages of a website, the easier the site is to maintain. Global changes need only be made to the tags defined in a central library, making time-consuming, page-by-page fixes things of the past.

For those XML lovers among us, good news: JSP pages can be written in well-formed, valid XML by using XSLT. (For those of you who aren't XML-spawn, this simply means that JSP can make full use of a very powerful and widely accepted data format and all the tools and support that go with it.)

And unlike ASP, JSP is a lot less platform-specific and it doesn't rely as heavily on the company that created it for support or performance improvements. That said, there are some similarities between JSP and ASP. Here, let's closer look at how the two compare.

next page»