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
- Download the sample web project.
- Select File>Import.
- Expand General, select Existing Projects into Workspace, and click Next.
- Select the Select archive file option, navigate to the downloaded zip file, and click Finish.
- 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.
- Right-click the MyEclipse Tomcat server in the Servers view, and select Add/Remove Deployments.
- 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.
- Verify that the deployment was successful by expanding the MyEclipse Tomcat server.
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.
- 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.
Switching back to the Servers view shows the server state of Debugging. - Right-click the project in the Servers view, and select Open in web browser. The JSP page loads.
- Expand the project’s WebRoot folder, and double-click index.jsp to open the editor.
- Select and delete “This is my JSP page,” and press CTRL+S to save.
- Click the Web Browser tab, and click to see your changes immediately.
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.
- 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. - Double-click the margin at line 33 to set a breakpoint (the line where the scriplet prints out the variables value).
- Go back to the Web Browser, and refresh the page to hit the 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. - Select that value, and adjust its value.
- Click to continue loading the page.
- Switch back to the web browser. Your new value for secretCode appears.