11.7. Editing web.xml in Place
Problem
You want to edit web.xml
in
Eclipse while keeping it in the Tomcat
directories.
Solution
Link to needed files such as web.xml
in your
project.
Discussion
To get access to web.xml
in Eclipse, even though
it’s in the
webapps\ch11\WEB-INF
directory, you can make it
a linked file
. To do that, right-click the
ServletInPlace
project, select New→
File, click the Advanced button, check the “Link to
file in the file system” checkbox, and click the
Browse button. Browse to the
webapps\ch11\WEB-INF
directory, and click Open.
Then in the New File dialog that appears, enter the name of the file
to link to, web.xml
, and click OK. This adds
web.xml
to the project, as shown in the Package
Explorer at left in Figure 11-6.
You can edit web.xml
to support the
ServletInPlace
servlet, as shown in Example 11-5.
Example 11-5. The new version of web.xml
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc. //DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>Example Applications</display-name> <servlet> <servlet-name>Servlet</servlet-name> <servlet-class>org.cookbook.ch11.ServletClass</servlet-class> </servlet> <servlet> <servlet-name>ServletInPlace</servlet-name> <servlet-class>org.cookbook.ch11.ServletInPlaceClass</servlet-class> </servlet> <servlet-mapping> <servlet-name>Servlet</servlet-name> <url-pattern>/org.cookbook.ch11.ServletClass</url-pattern> </servlet-mapping> <servlet-mapping> ...
Get Eclipse Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.