honzeland

记录点滴。。。

常用链接

统计

Famous Websites

Java

Linux

P2P

最新评论

J2EE学习笔记:

Part One: The Web Tier

Section One: Configuring Web Applications

Mapping URLs to Web Components

When a request is received by the web container it must determine which web component should handle the request. It does so by mapping the URL path contained in the request to a web application and a web component. A URL path contains the context root and an alias:

http://host:port/context_root/alias

A context root identifies a web application in a Java EE server. You specify the context root when you deploy a web module. A context root must start with a forward slash (/) and end with a string.
 
The alias identifies the web component that should handle a request. The alias path must start with a forward slash (/) and end with a string or a wildcard expression with an extension (for example, *.jsp). Since web containers automatically map an alias that ends with *.jsp, you do not have to specify an alias for a JSP page unless you wish to refer to the page by a name other than its file name.

Declaring Welcome Files

For example, suppose you define a welcome file welcome.html. When a client requests a URL such as host:port/webapp/directory, where directory is not mapped to a servlet or JSP page, the file host:port/webapp/directory/welcome.html is returned to the client.

If no welcome file is specified, the Application Server will use a file named index.XXX, where XXX can be html or jsp, as the default welcome file. If there is no welcome file and no file named index.XXX, the Application Server returns a directory listing.

To specify a welcome file in the web application deployment descriptor, you need to nest a welcome-file element inside a welcome-file-list element. The welcome-file element defines the JSP page to be used as the welcome page. Make sure this JSP page is actually included in your WAR file.

Setting Initialization Parameters

The web components in a web module share an object that represents their application context. You can pass initialization parameters to the context or to a web component.

To add a context parameter you need the following in the example's web.xml file:

  • A param-name element that specifies the context object
  • A param-value element that specifies the parameter to pass to the context object.
  • A context-param element that encloses the previous two elements.

To add a web component initialization parameter you need the following in the example's web.xml file:

  • A param-name element that specifies the name of the initialization parameter
  • A param-value element that specifies the value of the initialization parameter
  • An init-param element that encloses the previous two elements

Mapping Errors to Error Screens

Declaring Resource References


posted on 2006-10-13 15:53 honzeland 阅读(333) 评论(0)  编辑  收藏 所属分类: Java


只有注册用户登录后才能发表评论。


网站导航: