JSP - Servlets: Downloads and Configurations

  1. JDK, you can use the JDK offered by Sun at http://java.sun.com/javase/downloads/index.jsp

  2. Servlet container, which is a web server supporting the servlet technology. It corresponds to the Web Server and Application Server layers discussed in the JSP/Servlets development environment.

    Tomcat, GlassFish, and WebSphere (developed by Apache, Sun, and IBM respectively), are examples of web containers. In this tutorial, we are going to use Tomcat web server developed by Apache.

    For a list of web containers, visit Wikipedia at http://en.wikipedia.org/wiki/List_of_Servlet_containers

    You can get a preconfigured Tomcat version from http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat6.0-files/tomcat-6.0.16-preconfigured.zip

    Read about the Tomcat preconfigured version provided by coreservlets at the "Manual Tomcat Execution: Details" Section in http://www.coreservlets.com/Apache-Tomcat-Tutorial/

  3. IDE, standing for integrated development environment, is the tool that provides the developer, necessary facilities needed for his application implementation.

    JCreator, Eclipse, and NetBeans are examples of IDEs. In this tutorial, we will use Eclipse as it has a plug-in developed to enable us run Tomcat server directly from the IDE.

    For a list of IDEs, visit Wikipedia at http://en.wikipedia.org/wiki/List_of_IDEs and go to the "Java" section.

    You can download eclipse by choosing "Eclipse IDE for Java EE Developers" from http://www.eclipse.org/downloads/ or directly from here .

Since we are intending to run Tomcat server from eclipse, so we need to show Eclipse where is Tomcat folders. Please follow the following steps:

  1. Unzip Tomcat (in the ‘C' directory for example).
  2. Open Eclipse. Go to the folder where you saved eclipse and double-click

  3. Choose your workspace.Browse to the directory that you need to use as a workspace. A workspace is the place where your projects are saved. You may use an already existing folder to function as a workspace, or create a new one by browsing to the directory that you need your workspace to be placed in (C for example), and then writing the workspace name you like(the folder will be created automatically).

  4. Go to the workbench. When the Welcome page is opened, you can reach the workbench by clicking this icon

  5. Show the Tomcat-installation-folder to Eclipse:
    • Click the server tab at the bottom of your page. If it is not there, you can show it from: Window/Show View/ Servers or Window/Show View/ Other … / Server / Servers
    • Right-click any where at the servers zone / New / Server
    • Choose Tomcat v6.0 Server from Apache directory (folder)
    • Browse to the directory where you unzipped Tomcat (apache-tomcat-6.0.16)

  6. Copy some files:
    • Copy all files in the directory tomcat-installation-folder/conf
    • Past them in YourWorkspaceFolder/Servers/Tomcat v6.0 Server - In our example, it is C/ Workspace/Servers/Tomcat v6.0 Server - .
    • Refresh the Servers directory from the Project Explorer view
    • In the Project Explorer view R-Click Servers / Refresh
    Note that changes in the workspace folder are not recognized, unless you refresh the Project Explorer view.

  7. Start "Tomcat":
    • In the "Servers" view, R-click Tomcat-server record / Start
    • To check if Tomcat is running; In your browser, go to http://localhost/
    • The browser should open a "Directory Listing" page that looks like this:

    Note: This version of Tomcat (the pre-configured version) has a default port 80. So if you have another server working on port 80; you will have to change Tomcat's port from 80 to 8080

    Please follow the following steps to change the port:

    • Open "server.xml" from YourWorkspaceFolder/Servers/Tomcat v6.0 Server - In our example, it is C/ Workspace/Servers/Tomcat v6.0 Server/conf - .
    • Comment this part using XML comment tags <!-- ….. -->

      <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

    • Uncomment this part by removing the comment tags

      <!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> -->

      View final code of servers.xml
    • Refresh the Servers directory from the Project Explorer view. In the Project Explorer view R-Click Servers / Refresh.

    In this case, you will open Tomcat and view your projects using the URL http://localhost:8080 instead of http://localhost

  8. View Internal Web Browser (optional): You can open an internal web browser in eclipse from Window / Show View / Other… / General / Internal Web Browser

RenewSession