An Overview of JSP Technology


When a Web site needs to move from the delivery of static information to the delivery of dynamic content, the developer must decide which scripting language to use to write the page. So many choices are available—JavaServer Pages (JSPs), PHP Hypertext Preprocessor (PHP), and Active Server Pages (ASPs), among others. Many of the choices are comparable to each other, and it's just a matter of selecting the language that fits the platform available and the philosophy of the shop where the language will be used. JSP is one of the more powerful options available.

In this chapter, we explore JSP and how to use it with the Resin application server to provide a comprehensive, dynamic computing environment.

Beginning JSP Usage

When the decision is made to move from a static page to dynamic, one of the consequences that comes into play is the mixing of presentation and business functionality. In many of the server-side scripting languages available, a dynamic page to retrieve information about the user might be structured in the following way:

 <?       'connect to database'       'verify connection' ?> <HTML> <BODY>    <!-display header information >!    <h1>User: <? Get username ?> </h1>    <?       'Get more information'       while (more accounts)          'display account information'       loop    ?> </BODY> </HTML> 

In this very simple example, we find the <HTML> presentation tags have had the scripting language tags directly inserted into them. While all of the server-side scripting languages require that the business tags be inserted into the HTML code, many languages put the large amounts of actual code in the tags instead of calls to the code necessary for a given piece of functionality. In other words, instead of having a method that connects to a database and verifies the connection, the scripting language shown here puts all of the connection code directly into the HTML code.

While this type of coding works, it means that both the Web designer and the Web developer have to change the same piece of code. When the designer has to alter the layout of the page, he or she will probably have to sit side by side with the developer in order to get the scripting language tags in the right place. When the development team needs to modify the functionality, they will have to read through all of the HTML code to find the scripting code. While this doesn't seem like a huge issue, it causes problems in a production setting. It would be much better to have a scripting language that takes advantage of an existing powerful language like Java and that allows minimal insertion into the HTML code. JSP is the right technology to provide this type of separation.




Mastering Resin
Mastering Resin
ISBN: 0471431036
EAN: 2147483647
Year: 2002
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net