Tuesday, May 13, 2008

Install and configure Tomcat for Windows (How to and step by step)

Trying my hands full with Jahia (pronounce "J-A-Y-A"), an integrated Enterprise Content & Portal Management software in the open source, and a few documentation on my Tomcat installs... personally, for my own reference... hope this might become useful to anyone searching.... full disclaimer/s apply haha!

To install and configure Tomcat, you will have to take the following steps:

  1. Download JDK 1.5 from Sun(tm) site at http://java.sun.com/javase/downloads/index_jdk5.jsp

  2. Install JDK to C:\Program Files\Java\jdk1.5.0_08

  3. Download Tomcat 5 from http://tomcat.apache.org/download-55.cgi

  4. Install Tomcat on C:\Program Files\Apache Software Foundation\Tomcat 5.0

  5. Set the port number to 8080, which is the default port. Set the name as admin and password as desired. The password column can even be left blank.


  6. Set the environment variables as follows:
    • Right-click My Computer and select properties.

    • Click the Advanced tab button.

    • Click Environment Variables.

    • Select New to set the properties as follows:

      1. Classpath: In the variable name field write classpath, and in the variable value field write the location of servlet-api.jar file as C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar

      2. Path: In the variable name field write PATH, and in the variable value field write the location of JDK installation as C:\Program Files\Java\jdk1.5.0_08\bin;.;

      3. CATALINA_HOME: In the variable name field write CATALINA_HOME, and in the variable value field write the location of Tomcat installation as C:\Program Files\Apache Software Foundation\Tomcat 5.0.



      4. JAVA_HOME: In the variable name field write JAVA_HOME, and in the variable value field write the location of JDK installation excluding bin as C:\Program Files\Java\jdk1.5.0_08.



  7. Write a small Servlet program to test the installation as follows:

    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;

    public class TestServlet extends HttpServlet
    {

    public void doGet(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException
    {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("");
    out.println("");
    out.println("This is a Servlet test!");
    out.println("");
    out.println("");
    }
    }

  8. Compile the Servlet file and put the class file in webapps/servlets/WEB-INF/classes directory inside the Tomcat directory.

  9. Open a new textpad file and write the following code:

    TestServlet
    TestServlet



    TestServlet
    /test


  10. Save the above textpad file as web.xml in the webapps/servlets/WEB-INF directory.


  11. Go to C:\Program Files\Tomcat 5.0\bin directory and start tomcat by double clicking on the startup batch file.


  12. Open a new instance of Internet Explorer and type the following URL in the Address bar:
    http://localhost:8080/servlets/test

Note: Whenever any change is made to the servlet, it should be compiled again. In such a case, either restart the Tomcat server or redeploy the application by going to http://localhost:8080/manager/html.

Source:
the fastest way to IT certification

2 comments:

website cms said...

Thanks for the posts we are the professional web design and development company offering an array of services like template customization,web designing, CMS solutions, eCommerce solutions, Search engine optimization and Internet marketing.
WEBSITE CMS

Partner Portal said...

Awesome, thanks for the steps and tips. More power.

This blog has been archived and is not maintained any longer. For similar useful posts, please visit www.jeromeesperanza.com

Search

Google