jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes Tomcat installation on Windows2000 Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tomcat installation on Windows2000 Server" Watch "Tomcat installation on Windows2000 Server" New topic
Author

Tomcat installation on Windows2000 Server

Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319
Hello,
I am the greenest greenhorn ever! I wish to begin to work with servlets. I am running IIS on Windows2000 Server so I must install a servlet engine. I decided to use Tomcat.
In the documentation for Tomcat 3.2, I read the following:
2. INSTALLING AND RUNNING TOMCAT
Tomcat requires a Java Runtime Environment conformant to JRE 1.1 or later,including any Java2 platform system. If you wish to develop applications, you will need a Java compiler, such as the one included in a Java Development Kit 1.1 or later environment, including JDKs conformant with Java2.
For detailed information about installing and running Tomcat, point your browser at file "doc/uguide/tomcat_ug.html" under the directory into which you unpacked the Tomcat distribution.

I do not find this file, tomcat_ug.html, on my PC. I downloaded
nuts13rn.zip and unpacked it. Is this the correct file to download for Windows2000 Server?
Maybe I am going about this all wrong. If so, please be patient and help me get started down the right track.
Thank you very much,

Betty
Manjunath Subramanian
Ranch Hand

Joined: Jul 18, 2001
Posts: 236

Hello Betty,
If you have installed Tomcat,then in the bin directory you will find the necessary batch files,like startup.bat and shutdown.bat.Execute the startup.bat to start
the server.If it has started successfully,then open the broswer
and type this in the location bar.. http://localhost:8080/index.html.
This will launch the welcome page for tomcat server.You can get through to the documentation from here.
I haven't worked on Tomcat3.2,but i downloaded Tomcat4.0/b7 a couple of days back and it works fine..
The link to download Tomcat4.0 is, http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0-b7/.
Hope this helps
Manjunath
ernest fakudze
Ranch Hand

Joined: Aug 27, 2001
Posts: 216
Also Betty, please ensure that you have told Tomcat the directory of your JDK (you should install JDK 1.3)installation. Tomcat uses JDK to compile and run you JSPs.
In order to tell Tomcat where JDK is you should launch a text editor such as Notepad and open the tomcat.bat file (search for it if you do not know where it is (do not double-click on the file because it will execute.
In my tomcat.bat file i have
set JAVA_HOME=C:\Jdk1.3
to tell Tomcat where JDK is. Your Java dir may be different.
I know how frustrating it can be to ry and get a head start with JSP but hang in there and it will all soon work.
Good luck greenhoner!!

[This message has been edited by ernest fakudze (edited August 31, 2001).]


In a time of drastic change it is the learners who inherit the future. The learned usually find themselves equipped to live in a world that no longer exists.<br />Eric Hoffer
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319
I think I made a basic mistake. I downloaded the jakarta-servletapi-3.2.3 instead of jakarta-tomcat-3.2.3. How do these work together? If there is a README I am missing, I will be glad to go read it if you point me in the right direction. I used to support Oracle's web server, believe it or not.
Also, I do not know the difference in all those possible download files at http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.3/bin/
What does the ".asc" extension mean? Which one of these should I download? Also the .qz extension?
I have set TOMCAT_HOME and JAVA_HOME.
Thank you for your patience.
Betty
[This message has been edited by Betty Schwartz (edited August 31, 2001).]
mocca az
Ranch Hand

Joined: Mar 07, 2001
Posts: 93
Ok, lets determine something. You have downloaded, installed and configured jdk1.3. let say your installation directory is C:\jdk1.3
Now, you need to download servlet container (tomcat in this case), which you need to download from the link specified in previous post http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0-b7/
File that you need to download is "jakarta-tomcat-4.0-b7.zip" since you are running win2000. Nevermind the other .gz, .blah files. They are the same tomcat version for diferent operating systems such as unix, linux....
Now, unzip the file in some directory, let say C:\Tomcat
With this configuration your
JAVA_HOME = C:\jdk1.3
TOMCAT_HOME = C:\Tomcat
Now, go to your C:\Tomcat\bin directory and find startup.bat
double click on it and that will start Tomcat. It will open up command window and you will see what it does. To stop tomcat double click shutdown.bat.
You will also see startup.sh and shutdown.sh which are the files to start and stop tomcat on unix machines. There are also some configuration files but "at this stage startup.bat and shutdown.bat is all you need to know in order to run Tomcat".
If everything was successefule in your C:\Tomcat\webapps directory you should find the following folders
/admin
/examples
/ROOT
/test
Now, open up your browser and type http://localhost:8080/
If everything was correctly installed and configured it will open up the Tomcat welcome page.
If you have any other questions, please let me know.
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319
Can anyone recommend a good book on configuring Tomcat? I just need some documentation. It is up and running although I'm not sure why the links don't work on the documentation I have.
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319
Mocca,
Thank you for your instructions. I actualy have the 3.2.3 version running on Windows2000. If I got it started ok, are there going to be future problems with that version?
I don't know how to set up other directories for my servlets, etc. That is why I was wondering about a good book or maybe you can tell me. I don't want to use the directory where Tomcat has all of its examples.
If you go to http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.3/bin/
you will see there are servlet-api versions as well as tomcat versions to download. I have downloaded and installed and have running jakarta-tomcat-3.2.3.zip with the directories appearing that you indicate I should have. All is well with the install if it is now going to work for everything. I was leary of using the latest version because of something I read somewhere.

Thanks.
[This message has been edited by Betty Schwartz (edited September 01, 2001).]
mocca az
Ranch Hand

Joined: Mar 07, 2001
Posts: 93
Tomcat 4.0 is still in beta development. I have downloaded .exe and it configured itself, however i am still using 3.2. Books on Tomcat? I was looking for those, however i haven't found any. If you go to your local library and check out books on servlets/jsp usually each one has something on Tomcat, but its only configuration steps.
"I don't know how to set up other directories for my servlets, etc. "

In your Tomca\webapps create folder and call it whatever you want
exp. myproject. Restart tomcat and go to http://localhost:8080/myproject it should open up the myproject directory with the listings of files that you have in there. At this point you should have nothing. Create inedx.htm or index.jsp page and put it in Tomcat\myprojects now if you refresh your browser it should display that index page. In order for you to run .html or .jsp files this is all you need for the begining. If you want to run servlets and java beans you will also need to create WEB-INF directory and classes directory
Your directory structure should look something like this
Tomcat
|-- myproject
|-- WEB-INF
|-- web.xml
|-- classes

exp. C:\Tomcat\webapps\myproject\WEB-INF\classes
web.xml is a deployment descriptor. In this file you have to "register" your servlets, you can create servlet mapping, create welcome file list. I found out all of this from the different books, and i'll provide you with the info on how to set that up. I don't have it all with me now. Anyways, let me know if you have any other questions.

Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319
Thanks for all your information. I'm not able to work on this today, but I will try everything on Monday. This is exactly the kind of information I needed. Wow! I buy so many books so if you can give me definite suggestions, that will be helpful. I'm on a limited budget due to a downsizing and no work now for several months. Just trying to improve my marketability. Thank you very much for all the time you spend giving me direction.
mocca az
Ranch Hand

Joined: Mar 07, 2001
Posts: 93
Betty,
There are tons of books out there and i'd really have hard time to say which one is good and which one is not. I am in the same position as you are, out of work since late may, limited budget... I live in Phoenix, so my main source of literature is Phoenix Public Library, and they have some good books. If i have some "extra" time, i drive myself to nearby Borders, pick a few, seat down in a corner and read it. Almost every book covers the same material. I look for ones that are having sort of "build a project" type structure. Millions of links on the net as well. Depending on what you are trying to get into JSP or servlets, for me i learn both, since they are similar technologies, almost same. You can also find books with discounted prices on the amazon.com or try ebay...
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319

I was too curious about doing a servlet to wait until tomorrow. Mocca, you mentioned having to register a servlet and create servlet mapping, etc. When you can tell me how to do that, I would appreciate your help.
[This message has been edited by Betty Schwartz (edited September 02, 2001).]
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319
I have created "myServlets" directory in web-apps. My structure is
jakarta-tomcat-3.2.3
---- webapps
---- admin
---- examples
---- myServlets
--------- images
-------- META-INF
-------- WEB-INF
-------- HelloWorld.class
-------- HelloWorld.java
---- ROOT
---- test
I added the following to the server.xml file:
<!---Adding a context for myServlets 09/03/01 -->
<Context path="/myServlets"
docBase="webapps/myServlets"
crossContext="false"
debug="0"
reloadable="true" >
</Context>
<-- End add of 09/03/01 -->
When I enter http:\\localhost:8080\myServlets\HelloWorld, I get a 404 Not Found message. What have I missed? Does this have to do with registering the servlet in the web.xml file?
Also, when I try to go to the ContextAdmin home page, I am asked to login. I don't remember setting a username/password when doing the install. Do I need to work with this page and , if so, what about the login issue?
Thanks,

Betty
[This message has been edited by Betty Schwartz (edited September 03, 2001).]
[This message has been edited by Betty Schwartz (edited September 03, 2001).]
mocca az
Ranch Hand

Joined: Mar 07, 2001
Posts: 93
In order to run servlet you must "register" servlet in web.xml file. Each one of your applications will have web.xml file living in the WEB-INF directory of your application. In your case
X:\Tomcat\webapps\myServlets\WEB-INF\classes
X:\Tomcat\webapps\myServlets\WEB-INF\web.xml
Therefore in the hierarchy described above, you will need to add folder classes and web.xml file.
Now, in your web.xml file do the following
<web-app>
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>
where
<servlet-name>fully qualified servlet name
<servlet-class>fully.qualified.classpath (packagename and all that)
<servlet-name>fully qualified servlet name
<url-pattern>this is what you type in address bar of your browser to invoke the servlet. Here you can call it whatever you want.
So if you configure your web.xml as described you would access your servlet by typing http://localhost:8080/myServlets/hello
In your web.xml you can also do this
(put this within <webapp> tag)
<welcome-file-list>
<welcome-file>hello</welcome-file>
</welcome-file-list>
this should invoke your servlet by typing
http://localhost:8080/myServlets
you can also configure Tomcat to run on port 80 as opposed to 8080, but first make sure that IIS is disabled since IIS is using the same port. In order to do that you have to edit server.xml on the line
<Parameter name="port" value="8080"/> change value="80"
making this step will allow you to run your servlet by typing
http://localhost/myServlets
and if you further edit server.xml under your context
<Context path=""
docBase="webapps/myServlets"
crossContext="false"
debug="0"
reloadable="true" >
</Context>
you can just type http://localhost and it will bring up the index page or whatever you have set up in the welcome file of your web.xml
Check this out, http://www.netlibrary.com/ebook_info.asp?product_id=1894
This is book Java Servlets by Moss, Karl. It is an older version, but hey, its free. All you have to do is download small piece of software that will allow you to read the book.

mocca az
Ranch Hand

Joined: Mar 07, 2001
Posts: 93
I forgot.
All your servlets must live in the WEB-INF\classes directory of your webapp
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319
Thanks for the detailed instructions. I understand completely except that I'm getting that informative "404 Not Found" message. The HelloWorld.class file is in the
jakarta-tomcat-3.2.3\webapps\myServlets\WEB-INF\classes directory. I made the suggested changes to web.xml in
jakarta-tomcat-3.2.3\webapps\myServlets\WEB-INF.
To execute "HelloWorld", I enter: http://localhost:8080/myServlets/hello
I think I'll stick with port 8080 for now although I've helped customers change ports when I was with Oracle's support group so that's not a problem.
It was nice learning how to set up the welcome page, and I will do that as soon as one of these works!!!
I finally have an interview tomorrow so it would be good to get this working tonight. I'll give it a shot.
The sample web.xml which was in the examples/servlets/WEB-INF directory uses form based authentication. I'm not being asked to login, however. As I remarked earlier, I do not remember setting up a username/password for Tomcat. Was that part of the installation? I am going to try just a simple web.xml file now with only what you suggested in it and see if that works. Perhaps something in that sample web.xml file is causing myServlets not to execute.
Nope, just tried the 10-line web.xml you offered, and I still am not able to serve HelloWorld!!!
My web.xml:
<web-app>

<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> HelloWorld </servlet-name>
<url-pattern> /hello </url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>hello</welcome-file>
</welcome-file-list>
<web-app>
Is the fully qualfied name correct? I followed the example given by the Tomcat examples.
[This message has been edited by Betty Schwartz (edited September 05, 2001).]
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319
Still not able to serve servlets from myServlets directory. See anything I can correct?
I would appreciate any feedback on this issue. I am stymied as to a solution.
Thanks.
[This message has been edited by Betty Schwartz (edited September 10, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Tomcat installation on Windows2000 Server
 
Similar Threads
Tomcat getting stuck
tomcat servlet deployment on a mac
Tomcat startup.bat command not working
tomcat and web pages
Help Required.