Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Eclipse - Tomcat Setup

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 19

ECLIPSE – TOMCAT

SETUP & 1 ST

APPLICATION
SOFTWARES REQUIRED
 JDK 1.5
 ECLIPSE 3.4
 TOMCAT 5.0
 ECLIPSE PLUGIN – TOMCAT
 MYSQL DATABASE
 MYSQL JDBC DRIVER
JDK
 Copy jdk to your folder c:\programme

 Set classpath
 CLASSPATH
 .;C:\Programme\Java\jdk1.6.0_11;

 PATH
 %SystemRoot%\system32;%SystemRoot%;%SystemRoot
%\System32\Wbem;C:\Programme\ATI Technologies\ATI
Control
Panel;C:\Programme\QuickTime\QTSystem\;C:\Programme\
Java\jdk1.6.0_11\bin;
TOMCAT
 TOMCAT - RUN EXE FILE

 jakarta-tomcat-5.0.28.exe
 SET USER- admin , PASSWORD- admin

 Start the server from notification area (tray).


 Test it by entering link http://localhost:8080
ECLIPSE
 Download Eclipse J2EE version 3.4 or later
ECLIPSE PLUGIN FOR TOMCAT
 http://www.eclipsetotale.com/tomcatPlugin.ht
ml#A4
 tomcatPluginV321.zip
INSTALLATION
 This plugin does not contain Tomcat.
(Download and install Tomcat before using this plugin).
This is a design choice not to include Tomcat in the plugin distribution,
this way the same plugin version can works with any Tomcat version.

 Download tomcatPluginVxxx.zip
 Unzip it in :
- Eclipse_Home/dropins for Eclipse 3.4, 3.5 and 3.6
- Eclipse_Home/plugins for Eclipse 2.1, 3.0, 3.1, 3.2 and 3.3

 Plugin activation for Eclipse 3.x :


- launch eclipse once using this option : -clean
- if Tomcat icons are not shown in toolbar : select menu
'Window>Customize Perspective...>Commands', and check 'Tomcat' in
'Available command groups'
 The left button starts Tomcat, the middle
button stops it, the right button restarts
Tomcat. Right now, they won’t work if you
press them. To enable them, you first need to
configure a few things. Go to the menu
“Window-> Preferences” there, you will see
this dialogue box.
 Go to the menu item “Tomcat” and select your
Tomcat version. At the time of writing that
would be the 5.0 version.
 Now we adjust the field “Tomcat Home” to
point to the install directory that we selected
before at install time.
 To set a JDK as default JRE for Eclipse open the
preference window : Window -> Preferences -> Java
-> Installed JREs.
This JRE must be a JDK (This is a Tomcat
prerequisite).

 The plugin sets itself Tomcat classpath and


bootclasspath. Use Preferences -> Tomcat ->JVM
Settings, only if you need specific settings.
 Test http://localhost:8080/
CREATING HELLO WORLD
 stop out Tomcat server
 First, we need to open a new project in the
navigator window.
In the project window we select “Tomcat Project”…

                                      

…click on the Next button and call our new project “Hello World”

                                                         
After a click on the next Button we now can adjust under
which URI (Uniform Resource Identifier) we
want our new application to respond to our requests. To
illustrate what part of the URL this is, just take a look at the
fat part in the following address: http://localhost:8080/HelloWorld/hello.
The default adjustments on the other controls should be fine by
now, so we don’t bother to adjust them. They should look similar
to following image.

                                                                                           <>

If we now “Finish” the Wizard, we can see, that Eclipse has created a
whole bunch of new directories. It should look similar to this:

                                                          
 Now we can create a new class named
HelloServlet in the directory WEB-INF/src
 Copy the code
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
public class HelloServlet extends HttpServlet {
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
PrintWriter out = res.getWriter();
out.println("Hello, Brave new World!");
out.close(); } }
 Unfortunately we are not yet finished. We still
need to create the web.xml descriptor, which
contains certain elements of configuration
specific to our application and the server
behaviour. So we create the file web.xml in the
directory WEB-INF (Note: not in the
directory WEB-INF/src !!!). For our simple
application, the following parameters should
be fine.
 Check http://localhost:8080/HelloWorld/hello

You might also like