Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat 6 install on Mac 10.5.5

 
B Crosthwaite
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone

I am trying to install tomcat 6 (6.0.18) on my Mac OS X 10.5.5. so i can use servlets and JSP. I have managed to install tomcat 6 using this guide:
http://www.malisphoto.com/tips/tomcatonosx.html#Anchor-Database

I have changed my JAVA_HOME AND CATALINA_HOME directories.
CATALINA_HOME: /Library/Tomcat/Home
JAVA_HOME: /Library/Java/Home

and when i start tomcat i get this n the terminal:
Using CATALINA_BASE: /Library/Tomcat/Home
Using CATALINA_HOME: /Library/Tomcat/Home
Using CATALINA_TMPDIR: /Library/Tomcat/Home/temp
Using JRE_HOME: /Library/Java/Home

and i can get the tomcat home page ( http://localhost:8080/ )

I think Tomcat is set up correctly, if not please tell me

Now i am presented with 2 different problems.
1st) I cant compile an of my servlets. I get the error "javax.servlet does not exist" and "javax.servlet.http does not exist"
2nd) When i just place a JSP in the ROOT folder i get the all too familiar 404 error

Please can someone help me, iv been trying to get this sorted for days now :P

Thanks,
-Ben C
[ October 23, 2008: Message edited by: B.Crosthwaite ]
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you compiling the servlets? Is the servlet jar file in your classpath? Something like "javac -classpath $TOMCAT_HOME/common/lib/servlet-api.jar MyServlet.java" should do the trick.

The 404 problem is odd; that should work. But I'd leave the ROOT context alone, and create a separate directory instead, next to the ROOT directory. If you then create a WEB-INF directory inside of it, Tomcat will recognize it as a web app, and execute any JSPs you put in there.
[ October 23, 2008: Message edited by: Ulf Dittmer ]
 
B Crosthwaite
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ulf. This does make sence, but I have been a bit confused with the whole classpath thing. I will try this as soon as I can (I am at work at the moment :P )

-Ben
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by B.Crosthwaite:
but I have been a bit confused with the whole classpath thing.


What is the confusion? $TOMCAT_HOME is the Tomcat installation directory.
 
B Crosthwaite
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as the installation of tomcat goes this is my first time.

Is there a less time consuming way of compiling my servlets than this?
"javac -classpath $TOMCAT_HOME/common/lib/servlet-api.jar MyServlet.java"

-Ben
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you progress past the beginning stages with your web projects, you'll likely start using a build system (like Ant) or an IDE. Either of those can take care of adding all required jar files to your classpath without you having to type them in every time.

Also, on OS X, you can add jar files to your classpath permanently by putting them into the /Library/Java/Extensions directory. Any jar files in that directory will be added to the classpath automatically.
 
B Crosthwaite
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I might be getting a bit ahead of my self here, but please be patient

For Example, if i create:
CLASSPATH $TOMCAT_HOME/lib/
This would possibly solve my problem?

-Ben
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This can be answered in a couple of ways. The easy one is, it might help you once you get the semantics of the classpath right. The classpath does not point to directories that contain jar files, it points to the jar files themselves. So setting CLASSPATH to $TOMCAT_HOME/common/lib/servlet-api.jar might work.

The more complex answer is: don't use CLASSPATH. Explaining why requires more time than I have, but that's something I've come to learn over the years. It gets more in the way than it helps, maybe not right now for you, but eventually it will. I'd advise to use the "-classpath" option instead. You said earlier that that was time-consuming, but you only really need to type that once, and then you use the up arrow in the console to re-execute the command, so it's not like you need to type it all the time.

You might also want to become familiar with Ant, which addresses all these issues. But I'd advise you to wait a bit, until you've learnt the ins and outs of using Java via the command line, and have a good understanding of the classpath.
 
B Crosthwaite
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, ok. Point taken, i think your rite. I need to familiarise my self with the basics first i think.

May i just ask another question, it may sound a bit silly but....
What does the "-classpath" part of the javac statement mean, and what is do?

Thank you,
-Ben
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It tells the compiler where the class files can be found that are required to compile this particular file.Same thing can be done using the -cp option (for lazy ones like me ). But the -classpath is recommended simply because its more readable than -cp
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And now since this topic is inclined towards compiling servlets and setting the classpath and all, I am moving this to the Beginners forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic