Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!

# compiling servlets and jsp and running in tomcat

Irfan Junedi
Greenhorn
Posts: 13
Hello,

I have installed tomcat5.5.26 in windows,now i want to know how to set new classpath and which files i need to import and place in which folders so as to compile my servlet and jsp programs..
I have used Sunappserver previously to compile servlet and jsp by setting path till .......j2ee.jar
Waiting for responses..

Ben Souther
Sheriff
Posts: 13411
Tomcat compile your Java classes for you.
You have to do that yourself.

Irfan Junedi
Greenhorn
Posts: 13
dear sir,
It is giving me an error that package javax.servlet does not exist because i am pointing to jdk in my classpath..
I want the new one which i want to set in environment variables.

Ben Souther
Sheriff
Posts: 13411
See:
http://faq.javaranch.com/java/CompilingServlets

If you're not used to setting classpaths or using javac, let me know and I'll ask to have this thread moved to our Java In General (Beginner) forum where these things are usually covered.

Irfan Junedi
Greenhorn
Posts: 13
dear sir,
i want steps to set classpath so that my servlet get compilied..I know how to deploy on tomcat but the thing is compiling servlet..

And its 1.20 am here i want to compile this servlet nd sleep

Ben Souther
Sheriff
Posts: 13411
And its 1.20 am here i want to compile this servlet nd sleep

Heheh.
Let me see if I can get this moved to our Java In General forum where you'll get lots of help compiling your class so you can sleep.

-Ben

Ben Souther
Sheriff
Posts: 13411
What have you done to set your classpath so far?

Have you added servlet-api.jar to it?
The servlet-api.jar file can be found in tomcat/common/lib (or if you're using Tomcat 6: tomcat/lib).

How are you trying to compile your servlet classes?

See this FAQ for help pasting environment variables, etc.. into the ranch:
http://faq.javaranch.com/java/HowToCopyEnvironmentVariablesAndDirectoryStructures
[ May 05, 2008: Message edited by: Ben Souther ]

Amit M Tank
Ranch Hand
Posts: 257

And its 1.20 am here i want to compile this servlet nd sleep

Were you able to sleep, oops I mean compile the code?

Irfan Junedi
Greenhorn
Posts: 13
dear ben,
I have set my environment variables like this
catalina_home as C:\Program Files\Apache Software Foundation\Tomcat 6.0
java_home as c:\progarm files\java\jdk
path as c:\program files\java\jdk\bin
classpath as C:\program files\java\jdk\lib;C:\program files\java\jdk\lib;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar.

so any changes to be done to this,i am getting the same error