内に含まその他のドキュメントサポート リソース | PDF 文書ファイルをダウンロードする (1277 KB)
Chapter 2 Web Applications OverviewThis chapter provides a basic overview of how web applications are supported in Web Server. This chapter includes the following sections: Java Web ApplicationsWeb Server supports the Java™ Servlet 2.5 API specification and the JavaServer Pages™ (JSP™) 2.1 specification, which allows servlets and JSPs to be included in web applications. A web application is a collection of servlets, JavaServer Pages, HTML documents, and other web resources that include image files, compressed archives, and other data. A web application can be packaged into a web archive (WAR) file or exist in an open directory structure. Web Server 7.0 also supports, SHTML and CGI, which are not Java Platform, Enterprise Edition (Java EE) application components. For more information about APIs and programming technologies, see Sun Java System Web Server 7.0 Update 2 Developer’s Guide. Developing and Deploying Web ApplicationsThis section describes how to create, secure, and deploy web applications using Web Server. Creating Web ApplicationsThis section lists the general actions to create a web application, and provides pointers to more information.
About Securing Web ApplicationsYou can write secure web applications for the Sun Java System Web Server with components that perform user authentication and access authorization. You can build security into web applications using the following mechanisms:
For detailed information about these mechanisms, see Chapter 8, Securing Web Applications. About Deploying ApplicationsA web application is a collection of servlets, JSP, HTML documents, and other web resources that might include image files, compressed archives, and other data. A web application can be packaged into a Web ARchive file (a WAR file) or exist in an open directory structure. For more information, see Chapter 9, Deploying Web Applications. About Virtual ServersA virtual server is a virtual web server that uses a unique combination of IP address, port number, and host name to identify it. You might have several virtual servers all of which use the same IP address and port number but are distinguished by their unique host names. When you first install Web Server, a default virtual server is created. You can also assign a default virtual server to each new HTTP listener you create. For details, see Sun Java System Web Server 7.0 Update 1 Administrator’s Guide. About Default Web ApplicationsA web application that is deployed in a virtual server at a URL / becomes the default web application for that virtual server. To access the default web application for a virtual server, type the URL for the virtual server but do not supply a context root. For example: http://myvirtualserver:3184/ If none of the web applications under a virtual server are deployed at the URI ”/”, the virtual server serves HTML or JSP content from its document root, which is usually instance_dir/docs. To access this HTML or JSP content, point your browser to the URL for the virtual server specify the target file rather than a context root. For example: http://myvirtualserver:3184/hellothere.jsp Servlet Result CachingThe Web Server can cache servlet or JSP results to make subsequent calls to the same servlet or JSP page faster. For more information about response caching as it pertains to servlets, see Caching Servlet Results. JSP Cache TagsJSP cache tags enable you to cache JSP page fragments within the Java engine. Each can be cached using different cache criteria. For example, if you have page fragments to view stock quotes and weather information, you can cache the stock quote fragment for 15 minutes, and the weather report fragment for 25 minutes. For more information about JSP caching, see JSP Cache Tags. Database Connection PoolingDatabase connection pooling enhances the performance of servlet or JSP database interactions. For more information about the JavaTM DataBase Connectivity (JDBCTM) software, see Configuring JDBC Resources in Sun Java System Web Server 7.0 Update 1 Administrator’s Guide. The simplest connection pool can be configured by using the given. In this example, the connection pool is assigned to use the ORACLE JDBC driver.
|
$ ./bin/wadm --user=admin Please enter admin-user-password>user-admin-password Sun Java System Web Server 7.0 B01/02/2006 14:22 wadm> |
Verify the list of available configurations.
wadm>list-configs |
Create the jdbc-resource configuration.
For more information about all possible elements, see Sun Java System Web Server 7.0 Administrator's Configuration File Reference.
wadm>create-jdbc-resource --config=test --datasource-class=oracle.jdbc.pool.OracleDataSource jdbc/MyPool |
Add properties to jdbc-resource.
Properties are primarily used to configure the driver's vendor-specific properties. In the following example, the values for the properties url, user, and password are added to jdbc-resource.
wadm>list-jdbc-resource-userprops --config=test --jndi-name=jdbc/MyPool password=mypassword user=myuser url=jdbcZ:oracle:thin:@hostname:1421MYSID |
Enable the connection validation.
wadm>set-jdbc-resource-prop --config=test --jndi-name=jdbc/MyPool connection-validation-table-name=test connection-validation=table CLI201 Command "set-jdbc-resource-prop" ran successfully |
Change the pool setting.
In this example, the maximum number of connections is set to 100.
wadm>set-jdbc-resource-prop --config=test --jndi-name=jdbc/MyPool max-connections=100 CLI201 Command "set-jdbc-resource-prop" ran successfully. |
Deploy the configuration.
wadm>deploy-config test CLI201 Command "deploy-config" ran successfully. |
You can install a JDBC driver with Java Archive (JAR) files in one of the following ways:
Copy the driver's JAR file into the server's instance library directory. JAR files in the instance library directory will automatically load and available for server.
Modify the JVM class-path- suffix to include JDBC drivers jar file. The new value will overwrite the old value of the element. For example, wadm> set-jvm-prop --config=test class-path-suffix=/export/home/lib/classes12.jar
Sun Java System Web Server 7.0 includes a set of sample applications, which can be found in the install_dir/samplesfollowing directory.
All of the sample applications are arranged in a specific and well-defined directory structure. In general, the top-level directory of a sample application includes the following:
src: A directory containing all the Java source files, deployment descriptors, JSPs, and HTML files. Samples that use a database provide a script to populate data in the database.
docs: A directory containing all documentation for the application.
.WAR file: The deployable .WAR file for the sample application.
build.xml: A file for the ANT system to build the sample application
An ANT-based build system is used to build the individual sample application. The build.xml file has target to compile the sources, to clean, and to build the war file. It also has targets to deploy and undeploy the application, using the corresponding CLI commands provided by the Web Server. Register application resources in the deployment target.
Documentation is installed along with the samples during the installation. The index.html in the document root of the default Web Server instance contains links to the samples documentation. In addition, you can access the documentation HTML files directly in the samples directory.