Creating Web Projects

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

This feature is available in MyEclipse.

1. Create a Web Project

  1. SelectFile>New>Web Project.
  2. 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.

    hwnewwebproj
    Creating a new Web project

    Project name—The project’s name. Must be a valid Eclipse Java project name.
    Location—Clear the checkbox to specify a custom file-system location for the new project and its resources.
    Java EE version—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.
    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 runtime 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.
  3. Click Finish. 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.

    hwexplorer
    HelloWorld web project 

2. Create a JSP

  1. Right-click the WebRoot folder in the Explorer, and select New>JSP.
  2. 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.

    hwnewjsp
    Creating a new JSP page
  3. Click Finish to generate the helloWorld.jsp file in the WebRoot folder.
  4. Scroll to line 27 in the source view, press Enter to get a new line, and then type <% out.println("Hello World"); %>.
  5. Press Ctrl+S to 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.

3. Deploy the Project

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.

  1. Right-click the MyEclipse Tomcat server in the Servers view, and select Add/Remove Deployments.

    hwserversview
    Deploying the project from the context menu

  2. Select the HelloWorld project in the Available column, and click Add. 

    hwadddeployment
    Deploying to the MyEclipse Tomcat Server
  3. 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.
  4. 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. To access web properties, right-click the project and select Properties>Project Facets>Web This menu option was updated in MyEclipse 2017. For prior versions, click here. .

4. Test the Application

  1. Right-click the project, and select Run As>MyEclipse Server Application.
  2. 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.

    hwwebbrowser
    Viewing the HelloWorld project in the web browser

5. Debug the JSP

  1. Double-click helloWorld.jsp to open it in the editor.
  2. Double-click the left margin of the editor on the scriplet line to add a breakpoint.

    hwinsertbreakpoint
    Setting JSP breakpoint
  3. Right-click the project, and select Debug As>MyEclipse Server Application. Again, the browser opens the default index.jsp file.
  4. 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.

    hwdebugview
    JSP breakpoint activation

    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.