You are on page 1of 19

c 


       

M 
 

 


  

V 3 
 

V  
V      
V    
!V   "#
$ 
%V &
 "#
$ 
'V  ("#
$ 
)V & ("#
$ 
*V 


+V

V, -

3 
 

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.

top

 
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.

top
     
This tutorial was written using MyEclipse.

./ : ½  
 ½     
      
    
     
    ½
  
        !

   "     #     
 
½
# $
    ½        


% %%   ! & ' (%  $ 
%   & '
$
   '&
 )
*+&,-,).   ½/0
    

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.

top

    


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


top

!  "#


$ 
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  #


page that was created for us, we see a simple
example JSP:
Figure 7. Default JSP Page
top

%&
 "#
$ 
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 01 and click the M  &
 
button:

Figure 8. Manage Deployments

When the new deployment dialog pops up, click :

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.

top

' ("#
$ 
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 01 again and clicking the
& button. MyEclipse will switch to the 

01 and you want to
wait until you can see that Tomcat had started:
Figure 12. Tomcat Started Up

Switching back to the 01 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
( 233
 (
 2)+)+3 "#
$ 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 ( button, you should see your
changes immediately:
Figure 16. Refreshing the Browser Shows Changes
top

)& ("#
$ 
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 & and 


 views are synchronized. Also notice that we
declare our  1 variable with the value ) ,. Then we set a  -
 on
the line where the scriplet prints out the variables value. Let's go back to our "
4
1 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  1 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

 :

Figure 22. Click Continue

And flip back to the "4


1 to see if the value printed out for  1 to
the website was updated to what we typed in:
Figure 23. Updated Value Printed
top

*


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.

top

+

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.

|V Sample Web Project (Used in this Guide)


|V Application Server Tutorial
|V Working with Web Projects Tutorial

top

, -
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.

top