8/6/2019 Myeclipse Tomcat Server Tutorial
1/19
Deploying & Running Enterprise Applications > Getting Started
MyEclipse Tomcat ServerTutorialTable of Contents
1. Introduction2. Suggested Audience3. System Requirements4. Getting Started5. Creating a Web Project6. Deploying a Web Project7. Running the Web Project8. Debugging the Web Project9. Conclusion10.Resources11.Feedback
1. Introduction
Welcome to the MyEclipse Tomcat 6 Server Tutorial. Within MyEclipse an embedded
Tomcat 6 server is included to help developers get up and running immediately withtheir development work and not need to scour the net for an application server toinstall, download it, install it and configure it. Instead, with MyEclipse you'll be ableto immediately deploy your web project, run and debug it with no additional
configuration.
top
2. Suggested Audience
This tutorial is intended for developers who are somewhat familiar with MyEclipse'sApplication Server feature set and Java application servers like Tomcat.
To learn more about the topics presented in this tutorial, please have a look at thelinks in our Resources section. To get a better feel for MyEclipse and learning moreabout it, please check out our product Documentation for more material.
top
8/6/2019 Myeclipse Tomcat Server Tutorial
2/19
3. System Requirements
This tutorial was written using MyEclipse.
NOTE: Within MyEclipse JAX-WS reference implementation libraries are added tothe embedded MyEclipse Tomcat server to make development and testing of JAX-WSmuch easier. Deploying to an external Tomcat server or any other non-JavaEE 5
compliant server can require additional adjustments to the build path of any JAX-WS project, please see theJAX-WS Tutorialfor more information covering this.
MyEclipse Tomcat will work with all Java 5 and current 6 JDKs. However, if youwish to use a Java 6 JDK to run MyEclipse Tomcat, please use JDK 6 update 4
(1.6.0_04) or above to avoid JAX-WS API compatibility issues.
This tutorial was writtin using MyEclipse. However, if you notice portions of thistutorial looking different than the screens you are seeing, please let us know and we
will make sure to resolve any inconsistencies.
top
4. Getting Started
To get introduced to the new embedded Tomcat server, let's first look at the server
view:
Figure 1. Server View
where we see the new Tomcat server listed along side the embedded Derby DB
server. From this view we can start, stop, restart and manage the server'sdeployment.
Another popular place for managing the server status is from the toolbar application
server buttons:
8/6/2019 Myeclipse Tomcat Server Tutorial
3/19
Figure 2. Toolbar Application Server Controls
These sets of controls are simpler, but perform many of the same tasks. It's up toyou to decide which set of controls you'd rather use.
In addition to the new server controls, you can also access the embedded Tomcat 6preferences from the Application Server Connector preference pages similar tostandard application server connector configurations.
The embedded Tomcat configuration is referred to as the "MyEclipse Tomcat 6"connector as shown:
Figure 3. Embedded Tomcat 6 Preferences
8/6/2019 Myeclipse Tomcat Server Tutorial
4/19
top
5. Creating a Web Project
Now that we know how to control the new Tomcat server, let's take it for a testdrive. First thing we need to do is create a new Web Project to work with. Go ahead
and create a new simple Java EE 5.0 Web Project:
Figure 4. New Web Project
8/6/2019 Myeclipse Tomcat Server Tutorial
5/19
Figure 5. Configure the New Project
Our new project will look like this now:
8/6/2019 Myeclipse Tomcat Server Tutorial
6/19
Figure 6. Simple Web Project Contents
and if we open the example index.jsp page that was created for us, we see a simpleexample JSP:
8/6/2019 Myeclipse Tomcat Server Tutorial
7/19
Figure 7. Default JSP Page
top
6. Deploying a Web Project
Now that we have a Web Project to work with, we can deploy it to Tomcat 6 and
begin developing it in real-time. To add a deployment of our project to Tomcat, wewant to select Tomcat from the Server View and click the Manage Deploymentsbutton:
Figure 8. Manage Deployments
When the new deployment dialog pops up, click Add:
Figure 9. Creating a new deployment
8/6/2019 Myeclipse Tomcat Server Tutorial
8/19
Then filling in the deployment details (all the defaults are fine):
Figure 10. Creating a new deployment
And last you can verify that the deployment was successfully created under Tomcat:
8/6/2019 Myeclipse Tomcat Server Tutorial
9/19
Figure 11. Deployment was successful
Now that the deployment of the project to Tomcat is successful, all there is left todo is run Tomcat and view the page from inside the IDE.
top
7. Running the Web Project
The first thing we want to do to run this project is to first start up the embedded
Tomcat server. We do that by selecting it in the Server View again and clicking theDebug Server button. MyEclipse will switch to the Console View and you want towait until you can see that Tomcat had started:
8/6/2019 Myeclipse Tomcat Server Tutorial
10/19
Figure 12. Tomcat Started Up
Switching back to the Server View shows the server's status as well as it'sdeployments:
Figure 13. Server Running State
Now you want to click the Web Browser button up in the toolbar and navigate tohttp://localhost:8080/SimpleWebProject to see if your JSP page loads correctly. Ifit does, you should see the simple sample JSP page:
8/6/2019 Myeclipse Tomcat Server Tutorial
11/19
Figure 14. Simple JSP Page Running
To see some real-time editing in action, you can switch back to the JSP editor taband add some new text to the JSP page then save it:
8/6/2019 Myeclipse Tomcat Server Tutorial
12/19
Figure 15. Modify the Simple JSP Page
Now flip back to the Web Browser and hit the Refresh button, you should see yourchanges immediately:
8/6/2019 Myeclipse Tomcat Server Tutorial
13/19
Figure 16. Refreshing the Browser Shows Changes
top
8. Debugging the Web Project
Now that we have our project deployed and are able to change it and refresh to see
our changes, let's look at taking that control 1 step farther and debug ourapplication.
Debugging our application isn't just handy to stop at break points and inspect values;we can also change variable values on the fly during the debug session and see themrealized immediately in the application as it's running.
Let's take look at an example page with a scriptlet as follows:
8/6/2019 Myeclipse Tomcat Server Tutorial
14/19
Figure 17. JSP Page with a Scriplet
You can see that our Design and Source views are synchronized. Also notice that wedeclare our secretCode variable with the value h4x0r. Then we set a breakpoint on
the line where the scriplet prints out the variables value. Let's go back to our WebBrowser and refresh this page to hit the breakpoint:
8/6/2019 Myeclipse Tomcat Server Tutorial
15/19
Figure 18. Hitting a JSP Breakpoint
We can see quite a bit of information above. Namely that our Tomcat thread hasbeen suspended, our breakpoint has been hit and displayed in the bottom portion ofthe screen where we are stopped. Then at the top right hand side of the screen we
see the variables defined in our JSP page. We also see that our secretCode variablehas the right value.
Now let's say we wanted to change that value on the fly. We can simply right-click
on it, and adjust it's value right here:
8/6/2019 Myeclipse Tomcat Server Tutorial
16/19
Figure 19. Right-click to Change the Variable
Then type in a new value for the variable:
Figure 20. Enter the New Variable Value
After the new value is changed, you can see the updated value in the variables view:
8/6/2019 Myeclipse Tomcat Server Tutorial
17/19
Figure 21. Update Value
So now in order to see our changed value print out in our webpage, we need to hit
Continue:
Figure 22. Click Continue
And flip back to the Web Browser to see if the value printed out for secretCode tothe website was updated to what we typed in:
8/6/2019 Myeclipse Tomcat Server Tutorial
18/19
Figure 23. Updated Value Printed
top
9. Conclusion
Hopefully from this simple guide you can begin to get an idea of how fast you can
get up and running with the embedded Tomcat server that now ships with MyEclipsewhen working on your own projects.
We also hope that you've seen some of the power of working with MyEclipse duringthe development cycle and how that can increase your development efficiency.
top
10. Resources
In this section we want to provide you with additional links to resources thatsupplement the topics covered in this tutorial. While this is not an exhaustive list,we do make an effort to point to the more popular links that should provide you
with diverse, high-quality information.
y Sample Web Project (Used in this Guide)y Application Server Tutorial
8/6/2019 Myeclipse Tomcat Server Tutorial
19/19
y Working with Web Projects Tutorialtop
11. Feedback
We would like to hear from you! If you liked this tutorial, has some suggestions oreven some corrections for us please let us know. We track all user feedback aboutour learning material in our Documentation Forum. Please be sure to let us knowwhich piece of MyEclipse material you are commenting on so we can quickly pinpointany issues that arise.
top