JavaServer Pages (JSP) allows web developers to mix the power of HTML (Hypertext Markup Language) with the strength of Java to create web applications with unlimited potential. Although other web technologies, such as ColdFusion, can parse and execute text files containing programming commands mixed with HTML tags, JSP has the advantage of being intrinsically related to Java 2 Platform, Enterprise Edition (J2EE). This relationship allows JSP to leverage the full power of the Java language in a much simpler development environment. Another inherent difference between JSP and other web technologies is that JSP compiles script pages into Java servlets, small programs that a web browser can access without forcing the web server to interpret the script page each time it is called. This approach significantly reduces the resource demands on a web server.
To fully utilize JavaServer Pages and Dreamweaver MX, you need access to a JSP development environment. In addition, you need an understanding of the objects and syntax that make up JSP. The full breadth of Java and JSP are well out of the range of material we can cover in one chapter, so we'll focus our discussion on the most commonly used areas of the JSP language.
A JavaServer Pages (JSP) script file is a text file containing any combination of JSP and HTML code. However, as the JSP web server processes the text file, the server compiles the JSP script file into a servlet. Servlets are Java programs that can accept HTTP requests and send HTTP responses through a JSP web server. Typically, this process can be broken into several steps.
A web browser requests a page at a specific web address, such as www.sybex.com.
The web server hosting the www.sybex.com website accepts that request, locates the targeted page, and prepares to "serve" the page to the requesting web browser.
If the request is for a JSP page, the server passes the request to the server's servlet container. The servlet container controls the creation, use, and destruction of servlets. If this is the first request for the JSP servlet, the servlet container compiles the servlet from the JSP page and loads the servlet into memory. At this point, the servlet is ready to accept HTTP requests and send HTTP responses
The server forwards the HTTP request to the servlet, which subsequently sends the resulting HTML to the requesting web browser.
Java servlets are small programs written in Java to run within a Java Servlet Engine on a web server. Servlets can be a powerful web development tool. Java servlets are easily portable from one web environment to another and scalable from small to large implementations. In addition, servlets, which are compiled once and actually run inside the web server process, are typically less of a drain of a web server's resources than traditional web-scripting technologies that compile and render a script page upon each request.
This overview is just the tip of the iceberg. Since the code in a JSP page is actually Java, you're not limited to a single operating system or web server technology. In fact, you can easily port a JSP web application to any operating system and web server technology that supports the Java standard, which includes Windows and most flavors of Unix.
The primary focus of Java 2 Platform, Enterprise Edition (J2EE) is to simplify enterprise application development. J2EE accomplishes this goal in three ways. First, J2EE has sets of standardized, modular components that add additional functionality to the JSP language. Second, J2EE provides a complete set of web services to these standardized components. Third, J2EE automatically handles many details of application behavior— without requiring complex programming from the developers.
In addition, J2EE provides the same features that have made Java such a popular development tool— "Write Once, Run Anywhere," JDBC (Java Database Connectivity) for database access, CORBA (Common Object Request Broker Architecture) technology to interact with legacy enterprise systems, security to protect data, and full support for JavaBeans components, Java Servlets API (application programming interface), JavaServer Pages, and XML (Extensible Markup Language).