Deploying to the MyEclipse Tomcat Server

MyEclipse includes an embedded Tomcat server for quick testing during development without the hassle of installing and configuring an app server. This tutorial walks you through creating a project and deploying to the MyEclipse Tomcat server. You will learn how to:

  • Deploy a sample project
  • Run a project in the browser
  • Debug a project

This feature is available in MyEclipse.

1. Import a Sample Web Project

  1. Download the sample web project.
  2. Select File>Import.
  3. Expand General, select Existing Projects into Workspace, and click Next.
    Importing an existing project
  4. Select the Select archive file option, navigate to the downloaded zip file, and click Finish.
    Selecting an archive file to import
  5. Follow the wizard to migrate the project.

2. Deploy the Web Project

Now that you have a web project to work with, you can deploy it to  the MyEclipse Tomcat server and begin developing it in real-time.

  1. Right-click the MyEclipse Tomcat server in the Servers view, and select Add/Remove Deployments.
  2. Select SimpleWebProject in the Available column, and click Add. The default deployment mode is Exploded Archive, which lets you see your changes immediately without having to redeploy the application. Click Finish.
    Adding a project to the MyEclipse Tomcat server
  3. Verify that the deployment was successful by expanding the MyEclipse Tomcat server.
    Successful deployment

3. Run the Web Project

The first thing to do to run a project is to start up the MyEclipse Tomcat server. When the server is running, you can run or debug the application deployed to it.

  1. In the Servers view, select the MyEclipse Tomcat server, and click the Debug Server icon. MyEclipse switches to the Console view so you can see the server messages, including the start up confirmation.

    Tomcat start up confirmationSwitching back to the Servers view shows the server state of Debugging.

    Server running state
  2. Right-click the project in the Servers view, and select Open in web browser. The JSP page loads.
    JSP page running in the browser
  3. Expand the project’s WebRoot folder, and double-click index.jsp to open the editor.
  4. Select and delete “This is my JSP page,” and press CTRL+S to save.
    Modifying the JSP
  5. Click the Web Browser tab, and click to see your changes immediately.
    Refreshing the browser shows changes

4. Debug the Web Project

Debugging an application isn’t just about stopping at break points and inspecting values; you can also change variable values on-the-fly during the debug session and see them realized immediately in the application as it’s running.

The project’s JSP page contains a scriptlet. You will change the value of “secretCode” in the debugger.

  1. Switch back to the index.jsp tab, and click the Design tab at the bottom of the editor.

    You can see the Design and Source views are synchronized. Also notice the secretCode variable is declared with the value h4x0r.
  2. Double-click the margin at line 33 to set a breakpoint (the line where the scriplet prints out the variables value).
    JSP page with a scriplet
  3. Go back to the Web Browser, and refresh the page to hit the breakpoint.
    Hitting a breakpoint
    Quite a bit of information is displayed. The Tomcat thread has been suspended, and the breakpoint has been hit and displayed in the bottom portion of the screen where the application is stopped. At the top right-hand side of the screen, you can see the variables defined in the JSP page. You can also see that the secretCode variable has the assigned value.
    Note: If the Variable view is empty, click the appropriate line in the thread displayed in the Debug view. 
  4. Select that value, and adjust its value.
    Select variable to change the value
  5. Click  to continue loading the page.
  6. Switch back to the web browser. Your new value for secretCode appears.
    Updated value printed on the web page