Creating Web Projects in MyEclipse
This tutorial walks you through creating and deploying a simple Hello World web project. In this tutorial, you will learn how to:
- Create a Web project
- Create a JSP
- Deploy and test the project
- Debug JSP
Duration Time: 25 Minutes
Don't have MyEclipse? Download Now
- SelectFile>New>Web Project.
- Type HelloWorld into the Project name field.
The remaining fields are filled in automatically from the MyEclipse Web
project template. This template is defined in the project preferences.
Note: This tutorial uses the JavaEE 5 version; however, JavaEE 6 or 7 is an available option when creating new projects.
The project’s name. Must be a valid Eclipse Java project name.
Check the checkbox to specify a custom file-system location for the new project and its resources.
Specifies the JavaEE specification compliance level. Please ensure that you select the proper specification level for the JavaEE features your application requires and that your target deployment application server(s) support this specification level. Check with your application server vendor for information regarding Java EE specification level compliance.
Install JSTL libraries
Enabling this option results in the Java Standard Template Library JARs to be added to the new project.
Add Maven support
Enabling this option includes Maven project management support to your project. See Using Maven in MyEclipse for more information.
|Target Runtime||A run time is selected by default based on your chosen JavaEE version. A runtime must be selected for various containers (Spring, JPA, Struts, etc.) to appear on your project’s build path. You can change the runtime on the Runtime tab of the Project Properties> Project Facets page.|
Completing the wizard creates and configures the HelloWorld Web project. Notice the JavaEE Library container folder. This is a library of JavaEE API JARS provided by MyEclipse to your project for compilation and code completion support. These API JAR files are placed only in the project’s build path.
Note: No JavaEE JAR files or other resources are physically copied into your project.
- Right-click the WebRoot folder in the Explorer, and select New>JSP.
- The JSP wizard is a single page form that defines theJSP’s name and location in the project. The file path defaults to /HelloWorld/WebRoot. Type helloWorld.jsp in the File Name field, and select Default JSP template from the Template to use drop-down.
- Click Finish to generate the helloWorld.jsp file in the WebRoot folder.
- Scroll to line 27 in the source view, type the text <% out.println(“Hello World”); %>, and save the file.
Note: The specified JSP location was the WebRoot folder of the project. A location under the webroot folder is required to enable the JSP editor to fully provide code completion and validation features and for the MyEclipse Deployment Service to deploy the JSP.
In this step, you deploy the HelloWorld project to the MyEclipse Tomcat server. For application server configuration details, please review the application servers tutorial document.
- Right-click the MyEclipse Tomcat server in the Servers view, and select Add/Remove Deployments.
- Select the HelloWorld project in the Available column, and click Add. If allowed by the server connector, you can indicate either exploded or packaged deployment by using the drop-down list beside the module in the Configured column. For this example, accept the default exploded mode. Click Finish.
The context-root under which the project is deployed is /HelloWorld and is accessible at http://localhost-name:8080/HelloWorld. Recall that the context-root is a user-defined Web project property. Access web properties by right-clicking the project, selecting Properties, expanding MyEclipse, and choosing Web.
- Right-click the project, and select Run As>MyEclipse Server Application.
- Select the MyEclipse Tomcat server, and click OK. The default index.jsp appears in the built-in web browser. Type helloWorld.jsp at the end of the URL to view your hello world message.
- Double-click helloWorld.jsp to open it in the editor.
- Double-click the left margin of the editor on the scriplet line to add a breakpoint.
- Right-click the project, and select Debug As>MyEclipse Server Application. Again, the browser opens the default index.jsp file.
- To debug helloWorld.jsp, append the URL with helloWorld.jsp, and press Enter.
The MyEclipse workbench activates the Debug perspective due to the breakpoint in the file. The execution suspends at the breakpoint. The suspended line is marked with inverted color background and foreground colors. All Java variables and constructs are visible and available for modification in the Variables view. Additionally you can select a parent stack-frame in the Stack view and invoke “Drop to frame” to rollback the stack and reenter the JSP. Doing so allows you to step through execution of the JSP line by line.
Note: If execution continues past the breakpoint without suspending, check the breakpoint marker. If it does not include a checkmark , then it has not been registered and activated with the Tomcat JVM. This typically occurs when your server does not support the JSR045 specification to enable native JSP debugging on your project. In such cases, review the server provider’s release notes, e.g., Tomcat 4.X does not support JSP debugging natively.