eclipse – tomcat setup

Upload: saurabhzee

Post on 08-Apr-2018

238 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    1/19

    ECLIPSEECLIPSE TOMCATTOMCAT

    SETUP & 1SETUP & 1

    STST

    APPLICATIONAPPLICATION

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    2/19

    SOFTWARES REQUIREDSOFTWARES REQUIRED

    JDK 1.5JDK 1.5

    ECLIPSE 3.4ECLIPSE 3.4

    TOMCAT 5.0TOMCAT 5.0 ECLIPSE PLUGINECLIPSE PLUGIN TOMCATTOMCAT

    MYSQL DATABASEMYSQL DATABASE

    MYSQL JDBC DRIVERMYSQL JDBC DRIVER

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    3/19

    JDKJDK

    Copy jdk to your folder c:Copy jdk to your folder c:\\programmeprogramme

    Set classpathSet classpath

    CLASSPATHCLASSPATH .;.;C:C:\\ProgrammeProgramme\\JavaJava\\jdk1.6.0_11;jdk1.6.0_11;

    PATHPATH

    %SystemRoot%%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%system32;%SystemRoot%;%SystemRoot%\\SysSystem32tem32\\Wbem;C:Wbem;C:\\ProgrammeProgramme\\ATI TechnologiesATI Technologies\\ATI ControlATI ControlPanel;C:Panel;C:\\ProgrammeProgramme\\QuickTimeQuickTime\\QTSystemQTSystem\\;;C:C:\\ProgrammeProgramme\\JavaJava\\jdk1.6.0_11jdk1.6.0_11\\bin;bin;

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    4/19

    TOMCATTOMCAT

    TOMCAT TOMCAT -- RUN EXE FILERUN EXE FILE

    jakartajakarta--tomcattomcat--5.0.28.exe5.0.28.exe SET USERSET USER-- admin , PASSWORDadmin , PASSWORD-- adminadmin

    Start the server from notification area (tray).Start the server from notification area (tray).Test it by entering linkTest it by entering linkhttp://localhost:8080http://localhost:8080

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    5/19

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    6/19

    ECLIPSEECLIPSE

    Download Eclipse J2EE version 3.4 or laterDownload Eclipse J2EE version 3.4 or later

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    7/19

    ECLIPSE PLUGIN FOR TOMCATECLIPSE PLUGIN FOR TOMCAT

    http://www.eclipsetotale.com/tomcatPlugin.hthttp://www.eclipsetotale.com/tomcatPlugin.ht

    ml#A4ml#A4

    tomcatPluginV321.ziptomcatPluginV321.zip

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    8/19

    INSTALLATIONINSTALLATION

    This plugin does not contain Tomcat.This plugin does not contain Tomcat.(Download and install Tomcat before using this plugin).(Download and install Tomcat before using this plugin).This is a design choice not to include Tomcat in the plugin distribution, thisThis is a design choice not to include Tomcat in the plugin distribution, thisway the same plugin version can works with any Tomcat version.way the same plugin version can works with any Tomcat version.

    Download tomcatPluginVxxx.zipDownload tomcatPluginVxxx.zip Unzip it in :Unzip it in :

    -- Eclipse_Home/dropins for Eclipse 3.4, 3.5 and 3.6Eclipse_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.3Eclipse_Home/plugins for Eclipse 2.1, 3.0, 3.1, 3.2 and 3.3

    Plugin activation for Eclipse 3.x :Plugin activation for Eclipse 3.x :-- launch eclipse once using this option :launch eclipse once using this option : --cleanclean-- if Tomcat icons are not shown in toolbar : select menuif Tomcat icons are not shown in toolbar : select menu'Window>Customize Perspective...>Commands', and check 'Tomcat' in'Window>Customize Perspective...>Commands', and check 'Tomcat' in'Available command groups''Available command groups'

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    9/19

    The left button starts Tomcat, the middle buttonThe left button starts Tomcat, the middle button

    stops it, the right button restarts Tomcat. Rightstops it, the right button restarts Tomcat. Rightnow, they wont work if you press them. Tonow, they wont work if you press them. To

    enable them, you first need to configure a fewenable them, you first need to configure a fewthings. Go to the menu Windowthings. Go to the menu Window-->>

    Preferences there, you will see this dialoguePreferences there, you will see this dialogue

    box.box.

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    10/19

    Go to the menu item Tomcat and select yourGo to the menu item Tomcat and select your

    Tomcat version. At the time of writing thatTomcat version. At the time of writing thatwould be the 5.0 version.would be the 5.0 version.

    Now we adjust the field Tomcat Home toNow we adjust the field Tomcat Home topoint to the install directory that we selectedpoint to the install directory that we selected

    before at install time.before at install time.

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    11/19

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    12/19

    To set a JDK as default JRE for Eclipse open theTo set a JDK as default JRE for Eclipse open thepreference window : Windowpreference window : Window --> Preferences> Preferences --> Java> Java --> Installed JREs.> Installed JREs.

    This JRE must be a JDK (This is a TomcatThis JRE must be a JDK (This is a Tomcatprerequisite).prerequisite).

    The plugin sets itself Tomcat classpath andThe plugin sets itself Tomcat classpath andbootclasspath. Use Preferencesbootclasspath. Use Preferences --> Tomcat> Tomcat -->JVM>JVMSettings, only if you need specific settings.Settings, only if you need specific settings.

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    13/19

    TestTest http://localhost:8080/http://localhost:8080/

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    14/19

    CREATING HELLO WORLDCREATING HELLO WORLD

    stop out Tomcat serverstop out Tomcat server

    First, we need to open a new project in theFirst, we need to open a new project in the

    navigator window.navigator window.

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    15/19

    In the project window we select Tomcat Project

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

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    16/19

    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 dont bother to adjust them. They should look similar

    to following image.

    Ifwe now Finish the Wizard, we can see, that Eclipse has created a

    whole bunch ofnew directories. It should look similar to this:

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    17/19

    Now we can create a new class namedNow we can create a new class named

    HelloServlet in the directory WEBHelloServlet in the directory WEB--INF/srcINF/src

    Copy the codeCopy the code

    import java.io.*;

    import javax.servlet.http.*;

    import javax.servlet.*;public class HelloServlet extends HttpServlet {

    publicvoid doGet (HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException {PrintWriter out = res.getWriter();

    out.println("Hello, Brave new World!");

    out.close(); } }

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    18/19

    Unfortunately we are not yet finished. We stillUnfortunately we are not yet finished. We still

    need to create the web.xml descriptor, whichneed to create the web.xml descriptor, whichcontains certain elements of configurationcontains certain elements of configuration

    specific to our application and the serverspecific to our application and the server

    behaviour. So we create the file web.xml in thebehaviour. So we create the file web.xml in thedirectory WEBdirectory WEB--INF (INF (Note: not in theNote: not in the

    directory WEBdirectory WEB--INF/src !!!INF/src !!!). For our simple). For our simpleapplication, the following parameters should beapplication, the following parameters should be

    fine.fine.

  • 8/7/2019 ECLIPSE TOMCAT SETUP

    19/19

    CheckCheckhttp://localhost:8080/HelloWorld/hellohttp://localhost:8080/HelloWorld/hello