GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||
GeezerVison is showing javaee.github.io — Configuring Web Applications
Configuring Web ApplicationsThis section describes the following tasks involved with configuring web applications:
Setting Context ParametersThe web components in a web module share an object that represents their application context. You can pass context parameters to the context, or you can pass initialization parameters to a servlet. Context parameters are available to the entire application. For information on initialization parameters, see Creating and Initializing a Servlet. To Add a Context Parameter Using NetBeans IDEThese steps apply generally to web applications but do not apply specifically to the examples in this chapter. To add a context parameter using NetBeans IDE:
To Create a web.xml File Using NetBeans IDETo create a
Declaring Welcome FilesThe welcome files mechanism allows you to specify a list of files that
the web container can append to a request for a URL (called a valid
partial request) that is not mapped to a web component. For example,
suppose that you define a welcome file If a web container receives a valid partial request, the web container examines the welcome file list, appends to the partial request each welcome file in the order specified, and checks whether a static resource or servlet in the WAR is mapped to that request URL. The web container then sends the request to the first resource that matches in the WAR. If no welcome file is specified, GlassFish Server will use a file named
You specify welcome files in the
A specified welcome file must not have a leading or trailing slash
( The Mapping Errors to Error ScreensWhen an error occurs during execution of a web application, you can have the application display a specific error screen according to the type of error. In particular, you can specify a mapping between the status code returned in an HTTP response or a Java programming language exception returned by any web component and any type of error screen. You can have multiple To Set Up Error Mapping Using NetBeans IDEThese steps apply generally to web applications but do not apply specifically to the examples in this chapter. To set up error mapping using NetBeans IDE:
Declaring Resource ReferencesIf your web component uses such objects as enterprise beans, data sources, or web services, you use Java EE annotations to inject these resources into your application. Annotations eliminate a lot of the boilerplate lookup code and configuration elements that previous versions of Java EE required. Although resource injection using annotations can be more convenient for the developer, there are some restrictions on using it in web applications. First, you can inject resources only into container-managed objects, because a container must have control over the creation of a component so that it can perform the injection into a component. As a result, you cannot inject resources into such objects as simple JavaBeans components. However, managed beans are managed by the container; therefore, they can accept resource injections. Components that can accept resource injections are listed in Table 6-1. This section explains how to use a couple of the annotations supported by a web container to inject resources. Chapter 41, "Running the Persistence Examples", explains how web applications use annotations supported by the Java Persistence API. Chapter 51, "Getting Started Securing Web Applications", explains how to use annotations to specify information about securing web applications. See Chapter 55, "Resource Adapters and Contracts", for more information on resources. Table 6-1 Web Components That Accept Resource Injections
Declaring a Reference to a ResourceThe The In the following example, the
The container injects this data source prior to the component’s being
made available to the application. The data source JNDI mapping is
inferred from the field name, If you have multiple resources that you need to inject into one
component, you need to use the
The web application examples in this tutorial use the Java Persistence
API to access relational databases. This API does not require you to
explicitly create a connection to a data source. Therefore, the examples
do not use the Declaring a Reference to a Web ServiceThe
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| |||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |