facebook

Web Projects

Here you will find information about web projects.  You will learn about:

  • Web project structure and preferences
  • Web development productivity tools
  • JSP code completion and validation

This feature is available in MyEclipse.

1. Web Project Structure

In simplest terms, a MyEclipse Web project is an Eclipse Java project that includes metadata defining the project’s web nature and a directory structure patterned after the Java EE web archive (WAR) structure. Central to the Java EE Web project model is the Java EE deployment requirement that web applications conform to: 1) a standard WAR directory (folder) structure and 2) support the Eclipse JDT Java model concept of source folders.

The image below presents an annotated view of the structure of an example HelloWorld Web project. Note that MyEclipse Web projects are decorated with a small globe icon in the top-right corner of a project folder.  In this example project, two subfolders are shown: src and WebRoot. The src folder contains Java source code such as Java packages and their classes and interfaces. The WebRoot folder is the root or base folder of a folder structure patterned after the JavaEE web archive (WAR) structure. The root folder is formally known as the web-root and it contains three subfolders. Web content and resources such as JSP and HTML files, tag libraries, and JAR files are located in the web-root folder and its subfolders.


Example Web project file structure

The root folder of the web archive structure is known as the web-root. The actual name of this folder can be defined by you, but must adhere to the following structure and requirements:

WebRoot/
WEB-INF/
  lib/
  web.xml

WAR ElementsDescription
webroot

The root or base folder within a Web project under which all web content, executable and support resources reside. Any folder within the project, including the project folder, that includes the subfolder structure described here can serve as the webroot. Publicly accessible web content such as JSP and HTML files and their organizing subfolders typically reside directly in this folder.

WEB-INF/

A direct child folder of the webroot folder (i.e., <webroot folder>/WEB-INF). This folder and its subfolders contain the non-public application resources such as the web.xml deployment descriptors, tag libraries, compiled java classes, etc.

WEB-INF/lib

A child folder of WEB-INF that contains the project’s .JAR files 

web.xml

The Java EE web deployment descriptor that defines the Java EE web entities such as servlets and tag libraries. This file is required by Java EE web projects for deployment and execution. The web.xml file resides in the <web-root>/WEB-INF folder. MyEclipse interprets and maintains this file.

All Web projects using JavaEE versions prior to 5.0 are created with an empty deployment descriptor. For projects using Java EE 5 or higher, this file is not required and you have the option to have this file generated for you. You can modify the deployment descriptor file as needed.

The default names for the Java source and webroot folders are defined by the Web project template. See Web Project Preferences  to learn more about customizing Web project preferences.

The image below depicts the Resource perspective view of a MyEclipse Web project. This view reveals deployment information for the project. Project deployment can be customized using the project’s Deployment Assembly property. See MyEclipse Deployment Assembly for more information.



Resource perspective view of a Web project

Additionally, MyEclipse includes two special project members, the .settings folder and the .myeclipse folder. The .settings folder Holds all project settings. This folder should be treated with equal importance as the project’s corresponding Eclipse .project and .classpath files. If you are maintaining your project within a source management system, e.g., CVS,  include the .settings folder under version control.

The .myeclipse folder is MyEclipse’s transient work area for storing temporary data such as compiled JSPs. Because it is a temporary work area, it might be created and deleted dynamcially by MyEclipse Web tools and does not appear as part of a new project. It is generated automatically only if needed by the project. You do not need to maintain this folder under your source code control system. For example, if you are maintaining your project in CVS, we recommend adding .myeclipse to the project’s .cvsignore file.

Note: The .* files and folders might not be visible in your project. You must choose to view them using the Project Explorer filtering.

2. Web Development Productivity Tools

MyEclipse provides a number of productivity tools for the development of web applications. This section outlines the key tools and their use.

Editors

  • HTML Designer (source, WYSIWYG, preview modes)
  • JSP (source, preview modes)
  • XML, XSL (source, graphical modes)
  • DTD/XSD
  • Javascript
  • CSS
  • Text

All editors support user customizable syntax color highlighting, font, layout and formatting. The HTML, JSP, and XML editors provide real-time validation and error marking similar to the Eclipse Java editor.

Wizards

  • Web Project creation
  • HTML creation
  • JSP creation includes Struts
  • web.xml document creation and maintenance
  • XML creation

Validation

  • JSP including custom tags, and Java scriptlets
  • HTML
  • CSS
  • XML/XSL
  • Deployment descriptors

Deploy, Test, and Debug

  • Deploy directly from MyEclipse to test application serverenvironment
  • Support for over 20 different application servers
  • Launch and control an application server
  • Hot-swap/update debugging of JSP and Java code

Advanced Capabilities

  • Struts Designer and Wizards
  • XDoclet support
  • Java Server Faces support
  • Hibernate support

3. Web Project Preferences

MyEclipse provides a number of customizable preferences. You are encouraged to familiarize yourself with each of these. We have already seen several Web project wizards and windows with pre-populated fields. The value of many pre-populated fields is frequently derived from the MyEclipse system preferences. Two MyEclipse preferences that you should be aware of are the Web project folder template and deployment policies.

To access the MyEclipse preferences, select Window>Preferences, expand MyEclipse>Java Enterprise Project, and select Web Project.


MyEclipse Web project template preferences

Set the Web root folder name to “/” if you don’t want an explicit web root folder.

Note: Changing the Web project template affects only new projects, not existing projects.

4. JSP Code Completion

Double-click a JSP file to open it in the MyEclipse JSP editor. If you have an external JSP editor associated with JSP files, you can right-click the file, select Open With, and choose a different editor. Press CTRL+Spacebar to invoke MyEclipse code completion suggestions. The image below illustrates an example JSP code completion for Java scriptlets.


Invoking JSP code completion withCTRL+Spacebar

In addition to scriplet completion, MyEclipse JSP Editor provides code completion for JSP directives, e.g., `<%@ %>`, custom JSP tags, e.g.,` <x:if>`, and HTML tags. Use the CTRL+Spacebar keyboard shortcut to invoke all relevant forms of code completion.


JSP tag completion example


HTML tag completion example

5. JSP Validation

MyEclipse JSP validation capabilities can help identify JSP coding errors early in the development cycle at their precise point of occurance. This section introduces the two levels of JSP validation and how problems are identified in the JSP Editor and elsewhere in the workbench. The first level, or type, of JSP validation applies to the JSP editor. This editor is patterned after the Java editor and provides real-time, type-in validation on the editor’s contents. The second level of validation is a build-time action that is performed automatically on JSP files when they are modified and saved, or when a workspace “Clean” operation is performed on the project. See Enabling Automatic JSP Validation.

Lastly, manual JSP validation can be activated from the right-click context-menu on a single JSP file or recursively starting at a project or subfolder level.

5.1 JSP Editor Real-Time, Type-in Problem Detection

The JSP editor can detect a wide range of syntax and potential compilation problems as you enter source text. Warnings and errors that are detected in this manner are displayed in the JSP Editor’s overview column (right-hand side annotation column). You can enable/disable this behavior as well as modify the annotation colors by selecting Window>Preference, expanding General>Editors>Text Editors, and selecting Annotations.

Note: Real-time, type-in problems do not appear in the Problems view.  


JSP Editor real-time syntax checking error indicators

5.2 Automatic Build-Time Validation

The following example introduces a simple syntax error in helloworld.jsp to see how automatic validation works. Line 28 contains the following text:

<% out.println(“Hello World”) %>  

The ‘;’ to terminate the statement isintentionally omitted to illustrate error detection and marking.

During save the internal MyEclipse JSP compiler analyzes the JSP file for syntax and Java type correctness by compiling the JSP. Detected errors and warning are presented in a manner similar to that of the Java editor.

JSP validation and error marking

5.3 Manual Validation

At anytime, you can manually invoke JSP validation. Right-click any Web project file or folder in the Explorer view, and select MyEclipse>Run Validation. This causes JSP validation to be performed on the target resource(s). In the case of a selected folder or project, validation is performed recursively on all files and subfolders.


Invoking JSP validation from the right-click context menu