JSP for Designers
- Server-side Basics
- Using Included Files
- Using Variables
- Using Flow Control
- Be Creative
So you thought that JavaServer Pages was for programmers only? Not so. JSP can actually be a powerful tool that designers can use to build site layouts and design elements that are easy to change, easy to build, and downright cool.
Using simple HTML and JavaScriptthe usual tools of the designeryou are limited to controlling only what happens on the client side, or in the browser. JSP allows you to control what happens to the page before the page is sent to the browser.
This article will illustrate some basic methods in JSP that can be used by designers to make life easier and make their sites better. This is not meant as an introduction to JSP, but rather to illustrate some situations in which designers can benefit from server-side scripting using JSP.
Server-side Basics
To start off, you must first understand what server-side programming is. From this understanding, you will be able to realize what it can do for your programming.
In a typical Web page request, a client (someone using a Web browser) tells the Web server it wants a page (index.html, for example). As shown in Figure 1, the Web server simply sends the page to the browser. You know the rest: The HTML you wrote lays out the page and loads the Flash or images, and the user is immersed in a new Web experience.
Figure 1 A typical Web page request.
When JSP is used, the client requests the page from the Web server (such as index.jsp), which then notices that the page requested is a JSP page. Because of this, the Web server will first send the JSP to the JSP application server, such as Macromedia JRun. This process is shown in Figure 2.
Figure 2 A dynamic Web page request.
The application server then processes the JSP commands, and returns an auto-generated HTML page to the Web server, which promptly returns this page to the client.
Because of this extra processing, you (and your technical programmers) can add a bunch of scripting that can create really dynamic and cool Web pages. You can
access information from a database.
build pages unique to the visitor.
store information about the user.
embed dynamic images and Flash files.
use your imagination...
And the beauty of it all is that JSP makes all this really quite easy to do.