Database Reference
In-Depth Information
similar to those we have discussed for ADO.NET. The application creates a JDBC Connection
object , JDBC Statement objects , a JDBC ResultSet object , and a JDBC ResultSetMetaData
object . Calls from these objects are routed via the JDBC DriverManager to the proper driver.
Drivers then process their databases. Notice that the Oracle database in this figure could be
processed via either a JDBC-ODBC bridge or via a pure JDBC driver.
By ThE WAy By the way, most of this technology arose in the UNIX operating system
world (see: http://en.wikipedia.org/wiki/UNIX ) . UNIX is case sensitive, and
almost everything you enter here also is case sensitive. Thus, jdbc and JDBC are not
the same.
Prepared Statement objects and Callable Statement objects can be used to invoke com-
piled queries and stored procedures in the database. Their use is similar to the use of ADO.NET
Command objects discussed previously in this chapter. It is possible to receive values back from
procedures as well. Start at http://www.oracle.com/technetwork/java/javase/documentation/
index.html for more information.
Java Server Pages (JSP) and Servlets
Java Server Pages ( JSP) technology provides a means to create dynamic Web pages using
HTML (and XML) and the Java programming language. With Java, the capabilities of a com-
plete object-oriented language are directly available to the Web page developer. This is similar
to what can be done using ASP.NET using the Microsoft .NET languages.
Because Java is machine independent, JSP is also machine independent. With JSP, you are
not locked into using Windows and IIS. You can run the same JSP page on a Linux server, on a
Windows server, and on others as well. The official specification for JSP can be found at http://
www.oracle.com/technetwork/java/javaee/jsp/index.html .
JSP pages are transformed into standard Java language and then compiled just like a regu-
lar program. In particular, they are transformed into Java servlets, which means that JSP pages
are transformed into subclasses of the HTTPServlet class behind the scenes. JSP code thus
has access to the HTTP request and response objects and also to their methods and to other
HTTP functionality.
Apache Tomcat
The Apache Web server does not support servlets. However, the Apache Foundation and Sun
cosponsored the Jakarta Project that developed a servlet processor named Apache Tomcat
(now in version 7.0.40). You can obtain the source and binary code of Tomcat from the Apache
Tomcat Web site at http://tomcat.apache.org/ .
Tomcat is a servlet processor that can work in conjunction with Apache or as a stand-alone
Web server. Tomcat has limited Web server facilities, however, so it is normally used in stand-
alone mode only for testing servlets and JSP pages. For commercial production applications,
Tomcat should be used in conjunction with Apache. If you are running Tomcat and Apache
separately on the same Web server, they need to use different ports. The default port for a Web
server is 80, and Apache normally uses it. When used in stand-alone mode, Tomcat is usually
configured to listen to port 8080, though this, of course, can be changed.
Figure 11-22 shows the process by which JSP pages are compiled. When a request for a JSP
page is received, a Tomcat (or other) servlet processor finds the compiled version of the page
and checks to determine whether it is current. It does this by looking for an uncompiled ver-
sion of the page having a creation date and time later than the compiled page's creation date
and time. If the page is not current, the new page is parsed and transformed into a Java source
file, and that source file is then compiled. The servlet is then loaded and executed. If the com-
piled JSP page is current, then it is loaded into memory, if not already there, and then executed.
If it is in memory, it is simply executed.
 
 
Search WWH ::




Custom Search