Welcome Files

Web application developers can specify an ordered list of welcome files to be loaded when the request URL is not mapped to a servlet. These files are typically HTML or JSP documents. Welcome files are defined using the welcome-file-list element in the deployment descriptor. Element welcome-file-list contains one or more welcome-file elements. Each welcome-file element specifies the partial URL of a welcome file without a leading or trailing /. For example, the following welcome-file-list element indicates that index.html and index.htm are the welcome files.


To specify the welcome files for the jhtp6 context root, insert the preceding welcomefile-list element after the last servlet-mapping element in the web.xml deployment descriptor. When the URL http://localhost:8080/jhtp6/ is requested, the Web server appends each welcome file in the order specified in the deployment descriptor to the request URL, such as


and checks whether the resource is valid. The servlet container sends the request to the first matching welcome file. For example, if index.html exists in the jhtp6 directory, the servlet container sends the request to the http://localhost:8080/jhtp6/index.html. If no matching welcome file is found, the servlet container returns a response indicating that the resource is not available.

Figure 26.24 is the index.html that provides links (lines 1524) to test all the examples demonstrated in this chapter. Copy this file to C:jakarta-tomcat-5.0.25webappsjhtp6 and restart the Tomcat server. To test the welcome file, type the following URL in your Web browser:

Figure 26.24. Welcome file index.html.

(This item is displayed on page 1273 in the print version)

"http://www.w3.org/1999/xhtml"> 8 9

 1  "1.0" ?>
 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Welcome File 10 11 12 13

Click a link to test each example demonstrated in this chapter


15 <a href="</span"> "/jhtp6/servlets/WelcomeServlet.html"> 16 WelcomeServlet</a>
17 <a href="</span"> "/jhtp6/servlets/WelcomeServlet2.html"> 18 WelcomeServlet2</a>
19 <a href="</span"> "/jhtp6/servlets/WelcomeServlet3.html"> 20 WelcomeServlet3</a>
21 <a href="</span"> "/jhtp6/servlets/RedirectServlet.html"> 22 RedirectServlet</a>
23 <a href="</span"> "/jhtp6/servlets/Survey.html"> 24 SurveyServlet</a>

26 27


The index.html page is loaded. Click a link to test the corresponding servlet example.

Introduction to Computers, the Internet and the World Wide Web

Introduction to Java Applications

Introduction to Classes and Objects

Control Statements: Part I

Control Statements: Part 2

Methods: A Deeper Look


Classes and Objects: A Deeper Look

Object-Oriented Programming: Inheritance

Object-Oriented Programming: Polymorphism

GUI Components: Part 1

Graphics and Java 2D™

Exception Handling

Files and Streams


Searching and Sorting

Data Structures



Introduction to Java Applets

Multimedia: Applets and Applications

GUI Components: Part 2



Accessing Databases with JDBC


JavaServer Pages (JSP)

Formatted Output

Strings, Characters and Regular Expressions

Appendix A. Operator Precedence Chart

Appendix B. ASCII Character Set

Appendix C. Keywords and Reserved Words

Appendix D. Primitive Types

Appendix E. (On CD) Number Systems

Appendix F. (On CD) Unicode®

Appendix G. Using the Java API Documentation

Appendix H. (On CD) Creating Documentation with javadoc

Appendix I. (On CD) Bit Manipulation

Appendix J. (On CD) ATM Case Study Code

Appendix K. (On CD) Labeled break and continue Statements

Appendix L. (On CD) UML 2: Additional Diagram Types

Appendix M. (On CD) Design Patterns

Appendix N. Using the Debugger

Inside Back Cover

Java(c) How to Program
Java How to Program (6th Edition) (How to Program (Deitel))
ISBN: 0131483986
EAN: 2147483647
Year: 2003
Pages: 615

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net