Java Reference
In-Depth Information
Display 19.17
Running a Java Server Page (JSP) Program
C
C
S
C
Internet
1
Request
Web Server
Web Browser
HTML
3
2
HTML
JSP Servlet
Engine
The client's Web browser sends a request to the server for a Web page
that contains JSP code.
1
The JSP servlet engine dynamically compiles the JSP source code into
a Java servlet if a current, compiled servlet doesn't exist.
The servlet runs and outputs HTML that is returned to the Web server.
The Web server sends the servlet's HTML to the client's Web browser
to be displayed.
2
3
Oracle GlassFish Enterprise Server
JSP requires a Web server with a JSP servlet engine. In this section, we will use
the Oracle GlassFish Enterprise Server, previously known as the Sun Java System
Application Server. It is distributed by Oracle as part of the Java Enterprise Edition
SDK. However, you may use any Web server that supports Java servlets and JSP.
Another popular choice is the open source Apache Tomcat server. Follow the
installation instructions that come with the server that you select.
The GlassFish server will ask you to select an administrator username and password
during the installation procedure. It will also ask you for a location on the hard drive to
place the server files. We will refer to the pathname you select as <glassfish_home> .
On a Windows machine, this may default to C:\Sun\SDK . After the installation is
complete, start the GlassFish Web service. If the installation is successful, then you
should be able to see the administrator's page by opening http://localhost:4848
in your Web browser. The default URL for accessing applications is http:
//localhost:8080 . Substitute localhost with the name of the machine if you are
using a remote server.
At this point, you can test your server by creating or copying an HTML file into
<glassfish_home>\domains\domain1\docroot and opening it with your Web
browser. For example, if you create an HTML file named test.html in this directory,
then you should be able to access it with your Web browser by navigating to http:
//localhost:8080/test.html . If you cannot read the page, check your configuration
settings. To run JSP programs, your Web browser must open the page through the
GlassFish Web server and not directly load the page from the HTML file on the disk drive.
 
 
Search WWH ::




Custom Search