The objective of this section is to introduce the JavaServer Page technology.
So just what are JavaServer Pages ? A good place to start would be Sun's web site since they came up with the technology. Their definition is,
JavaServer Pages technology allows Web developers and designers to rapidly develop and easily maintain, information-rich, dynamic Web pages that leverage existing business systems. As part of the Java family, JSP technology enables rapid development of Web-based applications that are platform independent. JavaServer Pages technology separates the user interface from content generation enabling designers to change the overall page layout without altering the underlying dynamic content.(Sun)
What is being said here is that JavaServer Pages (JSP for short) simplifies the task of web developers in designing and maintaing dynamic web sites. Dynamic web sites differ from static web sites in that the web server will build a web page when it is requested by a user. For example, the online book resellers Amazon don't have a seperate web page for every single book they sell, instead their web server dynamically builds the page depending on what book the user requested to see, pulling the book information from a database. This keeps the web site smaller, more streamlined and, most importantly, more easily maintained.
JavaServer Pages are also "platform independent". This is because the technology is exploits Java server technology which is itself platform independent. This is more significant that you may at first think. Often a company will make their first steps in internet development on an NT machine purely because its cheaper to get started however if they are successful and need to scale up their web then they would probably consider migration to a Unix environment. If their web site was built using JSP then this is far more easily achieved than rewriting an Active Server Page based site to a Unix technology. Another reason for using JSP is that it is a much more advanced technology than ASP. Page execution is also faster than ASP since a JSP is compiled and executed rather than processed.
JavaServer Pages "separates the user interface from content generation". A good programming practice is to seperate the look and feel of the software from the business logic behind it. In this way the user interface can easily be changed without disrupting the applications logic. For a web site this is particularly important as the appearance of webs sites often change. JSP has features not available to ASP that make this seperation easier to achieve.
You can think of JSP as a type of server side scripting language similar to ASP although, as we'll see later, it operates quite differently behind the scenes. JavaServer Pages are text files usually with the extension ".jsp". A JSP file will contain a mix of traditional HTML plus some embedded Java code. When a request for a page is received by the server the HTML is passed straight through but the code portion, however, is executed and any content generated by this execution is added to the HTML. We'll see more details of this in the next two pages.
So JavaServer Pages are,