MyEclipse Web Project Quickstart
MyEclipse Web Project Quickstart
Last Revision:
Outline
1.
2.
3.
4.
5.
6.
Preface
Introduction
Web project concepts and terminology
Creating a web project
Overview of web development productivity tools
Creating a JSP document
1. Creating a JSP/a>
2. Editing JSP
3. Using code completion
4. Validating JSP
7. Deploy, test, and debug web project
1. Deploy web project
2. Test application
3. JSP debugging
8. Working with an existing web project
9. Customizing web project preferences
10.Advanced Features
1. Dependent Java project setup and deployment
2. Library deployment policy configuration
3. Adding Advanced Capabilities... to your Web Project
11.Summary
12.User Feedback
1. Preface
This document was written using Sun JDK 1.4.2, Eclipse 3.1 and MyEclipse 4.0. All screenshots were taken using the default settings for Eclipse, MyEclipse, and Windows XP. If you
experience difficulty with the instruction of this document, please see the User Feedback section for how to provide feedback to the MyEclipse documentation team.
Back to Top
2. Introduction
This Quick-Start presents the basic and advanced features, concepts, and techniques for rapidly getting started in the development of J2EE web applications using MyEclipse Web Tools.
Specifically, this document presents how to:
Back to Top
<project web-root>
WAR Elements
Description
web-root
The root or base directory within a Web Project under which all web content, executable and
support resources resides. Any folder within the project including the project folder itself (see
Figure 2 for an example) that includes the subdirectory structure may serve as the web-root.
Publicly accessible web content such as JSP and HTML files and their organizing
subdirectories typically reside directly under this folder.
WEB-INF/
A direct child directory of the web-root directory (e.g., <web-root folder>/WEB-INF). This
directory and its subdirectories contain the non-public application resources such
as deployment descriptors, tag libraries, compiled java classes, etc.
WEB-INF/classes
A child directory of WEB-INF that serves as the output location of the project's compiled Java
classes from the "src" folder(s). Contains *.class files and other non-Java resources from the
source tree. At runtime these resources are accessible from the System classpath.
WEB-INF/lib
web.xml
The J2EE web deployment descriptor that defines the J2EE web entities such as servlets and
tag libraries. This file is required by J2EE web projects for deployment and execution. The
web.xml file resides in the <web-root>/WEB-INF directory. MyEclipse web tools interpret and
maintains this file.
WEB-INF/
classes/
lib/
web.xml
Additionally, MyEclipse includes two special project members, the .mymetadata file and the optional .myeclipse folder. The .mymetadata file is an XML formatted file that defines MyEclipsespecific information such as the location of the web-root folder and other important details required by MyEclipse web tools for their proper operation. This file 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
.mymetadata file under version control.
The optional .myeclipse folder is MyEclipse's transient work area for storing temporary data such as compiled JSPs. Since it is a temporary work area it may be created and deleted
dynamcially by MyEclipse Web Tools. You do not need to maintain this folder under your source code control system. For example, if you are maintaining your project under CVS we
recommend adding .myeclipse it the project's.cvsignore file.
The default names for the Java source and web-root folders are defined by the Web Project template. See Section 9 to learn more about customizing Web Project preferences. Figure 2,
illustrates a Web Project for which the project folder serves as the web-root folder.
Description
Project name The project's name. Must be a valid Eclipse Java project name.
Location
Directory
The default file-system location for the project is under the workspace
directory for which MyEclipse was started. You may choose an
alternative file location outside of the workspace directory. Note: You
may not choose an alternate directory under the workspace directory as
this is not allowed by Eclipse.
The Java source folder - will contain Java packages and *.java
Source folder files. The contents of this folder are added to the project's Java build
path.
Web root
folder
The folder that will contain the web content, WEB-INF and its required
subfolders. If this field is empty or "/" then the project folder will serve as
the web-root folder.
Context root
URL
This is the context under which the MyEclipse Deployment Serivce will
use when deploying the new Web Project. The default value of the
context-root field is the name of the project. If you are unfamiliar with
the purpose of the context-root, it is the root portion of a URL that is
used to access this application when deployed, e.g.,
http://localhost:8080/HelloWorld. You may change the context-root field
to any alpha-numeric value that you prefer.
J2EE
specification
level
Enabling this option will result in the Java Standard Template Library
Add JSTL 1.0
(ver. 1.0) JAR's to be added to the new project's <web-root>/WEBlibraries
INF/lib directory.
Editors
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
Advanced Capabilities
Struts Designer and Wizards
XDoclet support
Java Server Faces support
Hibernate support
Back to Top
created in Section 4 .
Back to Top
Begin by creating a JSP named helloworld.jsp using the MyEclipse JSP wizard. Access this wizard as follows:
Open helloWorld.jsp in the MyEclipse JSP editor by double-clicking the file or from the "Open with..." context-menu action if you have a customized JSP editor associated for .jsp extension
files. Scroll to line 27 and enter the text, <% out . Followed by the ctrl->space key sequence to invoke MyEclipse code completion suggestions. Figure 8 illustrates an example JSP
code completion for Java scriptlets.
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
whenever they are modified and saved, or when a workspace "Clean" operation is performed on the project. Lastly, manual JSP validation may be activated from the context-menu on a
single JSP file or recursively starting at a project or subfolder level.
JSP editor's overview column (right-hand side annotation column). You may enable/disable this behavior as well as modify the annotation colors from the Workbench>Editor>Annotations
preference page.
Note: Real-time type-in problems will not appear in the Problems View.
3. Enable the project-specific validation from the project properties dialog. To access this dialog select the HelloWorld project in the Package Explorer view. Then from the context
menu (right-click menu) select Properties>MyEclipse-Validation and check the JSP Validation checkbox . See Figure 13 for an example.
Figure 18. Accessing the Deployment Management Dialog from the MyEclipse toolbar
Figure 19. Accessing the Deployment Management Dialog from a context menu
From the Deployment Wizard shown in Figure 20a & 20b, select Add followed by Tomcat 5 as the target server followed by Finish . This will deploy the Hello World project under the
Tomcat-5 work area in exploded WAR format. The context-root under which the project is deployed is "/HelloWorld" and is accessible at http://localhost:8080/HelloWorld . Recall
that the context-root is a user-defined Web Project property, see MyEclipse-Web properties available from the Web Project context-menu>Properties>MyEclipse-Web.
Open a web-browser to the URL location: http://localhost:8080/HelloWorld/helloworld.jsp. It will take several seconds to open this page as Tomcat must first compile the helloWorld.jsp page
before it can be presented. Your output should be similar to that of Figure 23.
Figure 30. Making the Logging Java project a dependent of the HelloWorld Web Project
The default deployment behavior for all Web Projects is defined by the MyEclipse system preferences (See Figure 31).
Deployer merges the Jar libraries of dependent Java projects that have
been explicitly exported. The libraries are copied into the WEB-INF/lib
folder of the deployment.
The default deployment behavior for all external libraries is defined by the MyEclipse system preferences (see Figure 33).
To add support for one of these technologies to your web project use its corresponding "Add Capabilities" wizard. Each technology addition wizard is accessible by selecting the target Web
Project and then invoking the wizard from either the MyEclipse context-menu (i.e., right-click menu) or the MyEclipse menubar entry.
11. Summary
This concludes the introduction to working with MyEclipse Web Projects. Additional Quickstart documents are available that into editing, application server configuration, enterprise
application and EJB project development, and database development. For more information visit the MyEclipse Quickstart library .
Back to Top