MyEclipse Logo
 

MyEclipse Deployment Descriptor Editor Tutorial

Outline

download the latest MyEclipse version

help and support
 

1. Preface

This document was written using MyEclipse. All screenshots are based upon the default user interface settings for MyEclipse and Windows Vista. If you experience difficulty with the instructions in this document, please see the User Feedback section for information on how to provide feedback to the MyEclipse documentation team.


 

2. Introduction

This document will cover some of the functionalities available in the MyEclipse Web XML Editor. The MyEclipse Web XML editor includes advanced XML editing functionalities like:

  • Syntax highlighting
  • Tag and attribute content-assist
  • Real-time validation (as you type)
  • Source, Design and Outline views of the document's contents
  • Document formatting
  • Content-assist templates

3. MyEclipse Web XML Editor

When you create a Web project, the New Web Project wizard places a default web.xml file in the project's WEB-INF directory. To open the web.xml file, double-click the Web Deployment Descriptor file in the Project Explorer view. The Web deployment descriptor editor opens in the editing pane. Even though the Web deployment descriptor editor does provides a source page of the web.xml file (from the Source tab), using the tree node is easier and introduces fewer errors. As you make changes on these pages, the web.xml file is updated automatically for you.

MyEclipse Web XML Editor

The tree structure is also shown in the Outline view and the Project Explorer view and provides easy navigation to the individual sections of the web.xml file.

Outline view
Project Explorer view

4. Web XML Editing

To edit the deployment descriptor, click the nodes in the tree to locate attributes that you wish to add, edit or remove. The Web deployment descriptor editor lets you specify deployment information for modules created in the Web development environment. The information appears in the WebContent/WEB-INF/web.xml file. Note that you use the Web deployment descriptor to set deployment descriptor attributes. You do not use it to manipulate Web resource content directly.

Editing web.xml files using the MyEclipse Web XML Editor can be done in two different modes: Design Mode and Source Mode. You switch between the two modes using the tabs at the bottom of the editor:

Switch-mode tabs

Switching between the two modes can be done any time as they are both kept in sync with each other automatically. First we will take a look at the Design Mode.


4.1 Web XML Design Mode

When you first open an web.xml document and switch to the Design Mode, it will look something like this:

Design Mode view

In this mode the contents of your web.xml document are shown to you in something of a super-outline-view.

On the left side you have the tags that make up your document represented in the form of a tree. Clicking on any of the tags in the tree will show the attributes for that tag in edit mode on the right side, making it very easy to visually understand and edit an web.xml file without worrying about syntax problems.

The Web deployment descriptor editor’s Tree tab includes the following nodes, each of which you can edit:

  1. Context Params
  2. Filters
  3. Listeners
  4. Servlets
  5. Session-config
  6. Mime Mappings
  7. Welcome-file-list
  8. Error Pages
  9. JSP Config
  10. Security Constraints
  11. Login-config
  12. Security Roles
  13. Env Entries
  14. EJB
  15. Services
  16. Resources
  17. Message Destinations
  18. Locale-encoding-mapping-list

Another nice feature of using the Design Mode is that you can add, remove and edit tags visually and the designer will make sure to only provide you with options that properly adhere to the DTD or Schema referenced by the document. More specifically, the design won't allow you to insert an invalid tag or attribute somewhere.

As an example, let's say we wanted to add a description to the first context-param argument in our XML document:

Adding a context-param

You will notice at this point in the document, according to the Schema referenced by our document, the only valid tags that can be inserted here is a child description tag, a comment tag or a generic processing instruction tag. If we click on the description tag, it is added and we can quickly edit the description to something we want:

Add Context Param.

Editing any of the tag values or adding/removing child tags can be done in this fashion without ever needing to switch to the Source Mode for editing. Although there can be times when editing the source directly can be helpful, so let's look at that next.

Editing a context param.


4.2 Web XML Source Mode

While editing XML documents in design mode can be easier at times and save you from making errors, it can also be handy to work directly with the source code. If that is the case MyEclipse's XML Editor provides extensive source-editing features that we will take a look at below.

When you first open your XML document to edit it, it will look something like this:

Source editor view

NOTE: The yellow underlines in the screenshot above are from the universal editor spell checker. You can enable or disable the spell checker for all editors based on your preference.

When using the XML source editor you will notice some very nice tooling as you work. For example, mistyping a tag or attribute name will get marked immediately for you as an error (checked against the DTD or Schema referenced by the doc):

XML errors are marked for you

And to help make editing easier, content-assist is available for tags and attributes. The content-assist is also context-aware, so it will not suggest illegal completion options to you based on the position of your cursor and the DTD or Schema the XML file is referencing:

Content-assist is everywhere

Alot of the functionality provided by the MyEclipse Web XML Editor is dependent on your document correctly referencing a DTD or Schema such that the editing tools can verify your work and provide content-assist against a specification. If you are editing a plain XML file that provides no DTD or Schema, the editor will still provide syntax highlighting and basic best-guess content-assist for you as well as basic validation (like unclosed tags) but some of the more advanced features for your editing won't be available.


5. Resources

This section provides some links to resources used during this guide.

  • web.xml - Example Web XML file used for the XML editing portion of this document.

6. User Feedback

If you have comments or suggestions regarding this document please submit them to the MyEclipse Documentation Forum.