Overview of JavaServer Pages

JavaServer Pages (JSP) is a technology that allows you to manipulate the content of HTML- or XML- based content on the web server, before it is delivered to the client. Other technologies, such as DHTML, manipulate content on the client side. While there are benefits to handling some things on the client side (such as form validation—making sure all mandatory fields are filled out correctly), in most cases, handling page manipulating is better done on the server side.

Some benefits to modifying text on the server side using JSP include:

  • Nobody can "borrow" code you spent weeks perfecting

  • You can interact with a database (both inserting and extracting)

  • Pages will load faster

  • There are no browser-compatibility issues

Borrowing code

Most of us do it. We find a web site that does something really cool, and we look at the source code for the page and copy the JavaScript code into our own pages. Some sites provide JavaScript code specifically for you to use...others, well, who's going to notice that their code has been copied?

With JSP, you won't have this issue. The code that you write remains on your server. All of its functionality is handled before the page is sent to a web browser.

Interfacing with a database

When you introduce the ability to insert data into, and extract data from a database into your documentation, your options suddenly become a lot wider. There are several sections on this site that delve into the subject of database functionality in JSP pages. While I recommend that you read the first few sections of this site in order, I know that I most likely would want to jump into that fun stuff first, with the intention of coming back to this page later. So, since you might be like me in that respect, here are the links to those sections: Database overview, Collecting form information, and Database-served pages.

Pages will load faster

When you use DHTML, JavaScript, or another client-side technology to customize content, you end up sending all of the content that the user might want, plus the code that is necessary to hide and reveal those sections. With JSP, you make all of the decisions about what the user wants to see, and send only the content that the user is interested in, with no extra code nor extra, unnecessary content.

There are no browser-compatibility issues

Those who develop JavaScript know that you had better check your code in several versions of several browsers, to make sure it will work as expected. You've got 2.0, 3.0, 4.0, and 5.0 browsers. You have Netscape, Internet Explorer, Opera, and more. Making JavaScript work in all of these requires that you either keep things very simple, or that you create custom code for some of the versions of some of the browsers.

JSP has no such requirement. You end up sending standard HTML to your users (though, you can put JavaScript in if you need to). This eliminates the issues with browser compatibility.

Other server-side technologies

There are other server-side technologies out there, including ASP, PHP, ColdFusion, web server scripting, CGI, and so on. There are many comparisons of these other technologies with JSP on the Web that you can review. But the short answer is that JSP is better than these because it:

  • Is compiled (faster performance)

  • Uses connection-pooling (faster performance)

  • Allows you to separate the programming logic from presentation (easier implementation)

Compiled vs. interpreted

The first time that a JSP page is visited on the web server, the source code is compiled into a Java bytecode servlet. This makes the loading time slightly higher the first time the page is accessed, but much faster every subsequent time. (Personally, I always load my JSP pages before making them publicly available, just so that it is already compiled.)

Technologies like ASP, PHP, and ColdFusion all interpret their code. This means that the slightly higher time that the JSP page takes the first time is a performance hit on ASP, PHP, and ColdFusion pages every time they are accessed. Also, the Java compiler optimizes its code when it compiles. The other technologies do not.

Connection pooling

The biggest part of the time spent accessing a page on a typical web server is used in the initialization stage. This is the part where the page is organized into the shape it needs to be when it is sent to the user. JSP enables connection pooling. What this means is that the initialization is handled once, for the first user who accesses the site. When that page has been sent to the user, instead of de-allocating its memory and closing its file, this is kept open, waiting for the next user to request the page. This is a very big improvement in performance...your online help is going to load much faster.

Separating programming logic from presentation

This is the Big Kahuna of JSP. Guess what? You don't need to know a lick of Java to be able to use some of JSP's functionality. There are thousands of JavaBeans and JSP tag libraries out there that you can buy off-the-shelf (or even download, free of charge) that you could use in your documentation. (I even sell a few, myself...see Modules for sale for more information.)

JSP uses tag libraries to separate code from your HTML pages. Basically, instead of having to learn Java, which you would then embed in your HTML pages (which is certainly an option), you can instead install a tag library, and use HTML-like tags to include the functionality in your site.

There are a couple of sections on this site that deal with tag libraries, so I won't go into more detail at this point. But if you want to read up on this, the most powerful aspect of JSP (as far as technical writers are concerned, anyway), feel free to skim these topics right now: Tag libraries and Tag Builder (a wizard for creating your own tag library).


Page last modified 06/14/2002