Won Contests Let Us Talk Mail Me Light of Knowledge


T omcat Install & Configuration
MUST READ TUTORIAL : Configuring Your Tomcat Server Version 3.2.1
  
Download Tomcat Server which is nothing but a simple zip file from this location jakarta-tomcat-3.2.1.zip or from its official website jakarta.apache.org

Step 1 :: Configuring Your Tomcat Server Version 3.2.1 - Right Directories

Download the zip file jakarta-tomcat-3.2.1.zip and extract it to d:\ so this will create a directory d:\jakarta-tomcat-3.2.1 rename this to d:\tomcat

Once you start your Tomcat by clicking on D:\tomcat\bin\startup.bat file Tomcat will start and unzip all .war files to the directories it likes them to be in,

Type in http://localhost:8080/ u must see an yellow cat. things have gone fine then.

If u get errors or your Tomcat Engine does not start you need to follow the tutorial below

Write d:\>m.bat by using a Simple DOS command
d:\>Edit m.bat


Step 2 :: Setting Environments

Open your notepad and write the lines shown below and save it as m.bat under D:\ Run m.bat from your Command promp OR DOS Prompt by typing
D:\> m


------------------------ Contents of m.bat
d:
SET JAVA_HOME=d:\jdk1.3.1
SET TOMCAT_HOME=d:\tomcat
SET CLASSPATH=d:\tomcat\lib\ant.jar;d:\tomcat\lib\jaxp.jar;d:\tomcat\lib\servlet.jar; d:\tomcat\lib\parser.jar;d:\tomcat\lib\webserver.jar;d:\tomcat\lib\jasper.jar
CD d:\tomcat\bin
startup
------------------------

 

If things go well then TOMCAT SERVER will open in a NEW WINDOW

 

Step 3 :: If things go Wrong and you dont see TOMCAT Window Then !

If things Go Wrong and your Tomcat Server Goes Off or Gives Error or Some Problem then checkout
1) Windows 98, Windows 95 users :: Open your C:\autoexec.bat and Edit it using notepad u must be able to see something like this

SET JAVA_HOME=d:\jdk1.3.1
SET PATH=c:\windows;c:\windows\command;d:\jdk1.2.1\bin;D:\ORACLE95\BIN;c:\
SET TOMCAT_HOME=d:\tomcat


2) Windows XP, Windows NT, 2000 and Advanced Server users ::
Right Click MyComputer
Click on Properties
Click on Advanced
Click on Environmental Variables
u must be able to see something like this

JAVA_HOME=d:\jdk1.3.1
PATH=%systemroot%\system32;%systemroot%;%systemroot%\system32\wbem;d:\jdk1.3.1\bin
SET TOMCAT_HOME=d:\tomcat


3) If you get out of environment error message Win98 users
Right Click DOS
Click on Properties
Click on Memory
Select Initial Environment = 2816

ALWAYS RESTART YOUR COMPUTER IF YOU CHANGE ANY SETTINGS

Step 4 :: If things go Right and TOMCAT Started !

open your internet Explorer and type in http://localhost:8080/index.html and u can play with servlet and JSP examples

 
Step 5 :: Package not found Error When you Compile !

Dont ask me why ? , But it is nessasary that all your java files must be in this Directory D:\tomcat\webapps\examples\WEB-INF\classes so u are in this directory and wanna compile a java file say index.java u can give the command like this D:\tomcat\webapps\examples\WEB-INF\classes>javac index.java , If its your good day u wont get any errors , else u will get a screen like this


SOLUTION : all u need to do is setup ur classpath properly just copy & paste (Type in MSDOS) this line in bold at
D:\tomcat\webapps\examples\WEB-INF\classes>
SET CLASSPATH=d:\tomcat\lib\ant.jar;d:\tomcat\lib\jaxp.jar;d:\tomcat\lib\servlet.jar; d:\tomcat\lib\parser.jar;d:\tomcat\lib\webserver.jar;d:\tomcat\lib\jasper.jar


Be carefull about any unwanted spaces ! and Re-Compile the java file D:\tomcat\webapps\examples\WEB-INF\classes>javac index.java If compiling goes right then u will not get that class not found Errors

Step 6 :: Setting up ODBC

If you wish to go further and your Application required you to set ODBC
Click on Start -> Settings -> Control Panel -> Administrative tools -> Data Sources (ODBC) -> User DSN -> Add -> Microsoft Access Driver *.mdb -> Finish

 

In Data Source name type in Example "shop" -> Select -> Driver D: -> Select the folder where you have your mdb file in my case d:\tomcat\database\shop.mdb -> Click OK -> OK again -> OK once more

 

Step 7 :: Accessing Your Java Files

Now that u have compiled ur index.java file to access the same file open ur internet Explorer type in http://localhost:8080/examples/servlet/index (REMEMBER NO .java or .class at the END of this Line )
by the way index.java is in my Jewels.zip file


Step 8 :: Suggestion

You can Email me at James Smith : james_smith73@yahoo.com , visit my website http://www.oocities.org/james_smith73 for Code Downloads and Tutorials or access all my java codes from www.planetsourcecode.com

NEW TOMCAT HIGHER VERSIONS - 4.1.27
I guess the guys have learnt from their mistakes , so this version is more stable after 3.2.1 and works better
1) Download jakarta-tomcat-4.1.27.exe from the jakarta.apache.org
2) Click on the EXE and install itin C:\Tomcat directory, i prefer this
3) check installation at http://localhost:8080 in your browser u must see the yellow cat
4) Save this file Below as HelloWorld.java in C:\Tomcat\webapps\examples\WEB-INF\classes Directory
5) go to above directory compile the code
C:\Tomcat\webapps\examples\WEB-INF\classes\>javac HelloWorld.java
if this go fine u wont get any error during compiling
6) In your browser type in http://localhost:8080/examples/servlet/HelloWorld then u will see My Hello World
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet 
{
    public void doGet(HttpServletRequest request, HttpServletResponse response) 
	throws IOException, ServletException
    {         
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head>");
	    out.println("<title>My Title</title>");
        out.println("</head>");
        out.println("<body bgcolor='white'>");
        out.println("<h1>My Hello World</h1>");
        out.println("</body>");
        out.println("</html>");
    }
}
Trouble shooting Errors in Tomcat Configuration
1) RightClick on MyComputer -> Properties -> Advanced Tab -> Environmental Variables -> System Variables
2) See your JAVA_HOME=C:\jdk1.3.1
3) Path=all otherpaths;C:\jdk1.3.1\bin
4) CATALINA_HOME=C:\TOMCAT
5) SET CLASSPATH=%classpath%;C:\Tomcat\common\lib\activation.jar;C:\Tomcat\common\lib\activation.jar;C:\Tomcat\common\lib\ant.jar; C:\Tomcat\common\lib\jasper-compiler.jar;C:\Tomcat\common\lib\jasper-runtime.jar;C:\Tomcat\common\lib\jdbc2_0-stdext.jar; C:\Tomcat\common\lib\jndi.jar;C:\Tomcat\common\lib\jta.jar;C:\Tomcat\common\lib\mail.jar;C:\Tomcat\common\lib\naming-common.jar; C:\Tomcat\common\lib\naming-factory.jar;C:\Tomcat\common\lib\naming-resources.jar;C:\Tomcat\common\lib\servlet.jar; C:\Tomcat\common\lib\tools.jar
6) Recompile ur java file and try to execute .........
 My Dream to be your Friend and Create a Group of Intelligent and Understanding Programmers
     If you like this article and/or code mailme or Join our small Java User Group which is by the Programmers for the Programmers ,
Till we meet next time BYE      Kind Regards - James Smith

  Java, J2EE, J2SE and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc.
in the United States and other countries.