|
|
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 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
you'll be able to immediately deploy your web project, run
and debug it with no additional configuration.
|
|
|
This 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.
|
|
This tutorial was written using MyEclipse.
NOTE:
Within MyEclipse JAX-WS reference
implementation libraries are 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.
MyEclipse Tomcat will work with all Java 5 and current 6 JDKs. However, if you wish 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 this tutorial looking different than the screens you are
seeing, please
let us know and we will make sure to
resolve any inconsistencies.
|
|
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's deployment.
Another popular place for managing the server status is from the
toolbar application server buttons:
|
Figure 2. Toolbar Application
Server Controls
|
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:
|
Figure 3. Embedded Tomcat 6
Preferences
|
|
5.
Creating a Web Project
Now 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:
|
Figure 4. New Web Project
|
|
Figure 5. Configure the New
Project
|
Our new project will look like this now:
|
Figure 6. Simple Web Project
Contents
|
and if we open the example
index.jsp page that was created for us, we see a simple
example JSP:
|
Figure 7. Default JSP Page
|
|
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:
|
Figure 8. Manage Deployments
|
When the new deployment dialog pops up, click
Add:
|
Figure 9. Creating a new
deployment
|
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:
|
Figure 11. Deployment was
successful
|
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:
|
Figure 12. Tomcat Started Up
|
Switching back to the
Server View shows the server's status as well as
it's deployments:
|
Figure 13. Server Running State
|
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:
|
Figure 14. Simple JSP Page Running
|
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:
|
Figure 15. Modify the Simple JSP
Page
|
Now flip back to the Web Browser and hit the
Refresh button, you should see your changes
immediately:
|
Figure 16. Refreshing the Browser
Shows Changes
|
|
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 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:
|
Figure 17. JSP Page with a
Scriplet
|
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:
|
Figure 18. Hitting a JSP
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:
|
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:
|
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 to the website was updated to what we typed
in:
|
Figure 23. Updated Value Printed
|
|
|
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 MyEclipse 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.
|
|
In 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.
|
|
We 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.
|