|
||||||||||||||
Table of Contents |
||||||||||||||
1. IntroductionWelcome to the MyEclipse Tomcat 6 Server Tutorial. In MyEclipse 6.0 an embedded Tomcat 6 server was added to help developers get up and running immediately with their development work and not need to scour the net for an application server to install, download it, install it and configure it. Instead with MyEclipse 6.0 you'll be able to immediately deploy your web project, run and debug it with no additional configuration. |
||||||||||||||
2. Suggested AudienceThis tutorial is intended for developers who are somewhat familiar with MyEclipse's Application Server feature set and Java application servers like Tomcat.
To learn more about the topics presented in this tutorial, please
have a look at the links in our
Resources section. To
get a better feel for MyEclipse and learning more about it,
please check out our product
Documentation for more
material.
|
||||||||||||||
3. System Requirements
This tutorial was written using MyEclipse 6.0 GA (All in One
installer).
NOTE:
In MyEclipse 6.5 and beyond the JAX-WS reference
implementation (Metro 1.1) libraries were added to the embedded
MyEclipse Tomcat server to make development and testing of
JAX-WS much 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
the JAX-WS
Tutorial for more information covering this.
If you are using a newer version of MyEclipse and notice portions
of this tutorial looking different than the screens you are
seeing, please
let us know and we will make sure to
resolve any inconsistencies.
|
||||||||||||||
4. Getting Started
To get introduced to the new embedded Tomcat server, let's first
look at the server view:
where we see the new Tomcat server listed along side the embedded Derby DB server that was added in MyEclipse 5.5. From this view we can start, stop, restart and manage the server's deployment. Another popular place for managing the server status is from the toolbar application server buttons:
These sets of controls are simpler, but perform many of the same tasks. It's up to you to decide which set of controls you'd rather use. In addition to the new server controls, you can also access the embedded Tomcat 6 preferences from the Application Server Connector preference pages similar to standard application server connector configurations. The embedded Tomcat configuration is referred to as the "MyEclipse Tomcat 6" connector as shown:
|
||||||||||||||
5. Creating a Web ProjectNow that we know how to control the new Tomcat server, let's take it for a test drive. 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:
Our new project will look like this now:
and if we open the example
index.jsp page that was created for us, we see a simple
example JSP:
|
||||||||||||||
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, we want to select Tomcat
from the
Server View and click the
Manage Deployments button:
When the new deployment dialog pops up, click
Add:
Then filling in the deployment details (all the defaults are
fine):
And last you can verify that the deployment was successfully
created under Tomcat:
Now that the deployment of the project to Tomcat is successful,
all there is left to do is run Tomcat and view the page from
inside the IDE.
|
||||||||||||||
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 the
Debug Server button. MyEclipse will switch to
the
Console View and you want to wait until you can
see that Tomcat had started:
Switching back to the Server View shows the server's status as well as it's deployments:
Now you want to click the Web Browser button up in the toolbar and navigate to http://localhost:8080/SimpleWebProject to see if your JSP page loads correctly. If it does, you should see the simple sample JSP page:
To see some real-time editing in action, you can switch back to
the JSP editor tab and add some new text to the JSP page then
save it:
Now flip back to the Web Browser and hit the
Refresh button, you should see your changes
immediately:
|
||||||||||||||
8. Debugging the Web ProjectNow 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 our application.
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 them realized
immediately in the application as it's running.
Let's take look at an example page with a scriptlet as follows:
You can see that our
Design and
Source views are synchronized. Also notice that
we declare 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
Web Browser and refresh this page to hit the
breakpoint:
We can see quite a bit of information above. Namely that our Tomcat thread has been suspended, our breakpoint has been hit and displayed in the bottom portion of the 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 variable has 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:
Then type in a new value for the variable:
After the new value is changed, you can see the updated value in
the variables view:
So now in order to see our changed value print out in our
webpage, we need to hit
Continue:
And flip back to the Web Browser to see if the value printed out for secretCode to the website was updated to what we typed in:
|
||||||||||||||
9. ConclusionHopefully from this simple guide you can begin to get an idea of how fast you can get up and running with th emebedded Tomcat server that now ships with MyEclipse 6.0 and later when working on your own projects.
We also hope that you've seen some of the power of working with
MyEclipse during the development cycle and how that can increase
your development efficiency.
|
||||||||||||||
10. ResourcesIn this section we want to provide you with additional links to resources that supplement 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.
|
||||||||||||||
11. FeedbackWe would like to hear from you! If you liked this tutorial, has some suggestions or even some corrections for us please let us know. We track all user feedback about our learning material in our Documentation Forum. Please be sure to let us know which piece of MyEclipse material you are commenting on so we can quickly pinpoint any issues that arise. |