• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to compile servlets

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Are my path & classpath correct for compiling servlets?

I downloaded the J2EE1.4 s/w bundle that includes

# Sun Java System Application Server Platform Edition 8.1 2005Q1
# J2SE 1.4.2
# J2EE 1.4 SDK Samples 2005Q1
# J2EE 1.4 API Documentation

I have also downloaded the tomcat 5.5.7 and the compat versions, set the java-home variable and got the tomcat welcome page successfully.

My path is set to:

c:\sue\projects\exercise\servlets;c:\J2EE1.4\bin;
c:\J2EE1.4\jdk\bin;c:\J2EE1.4\jdk\jre\bin;

My classpath is set to:

c:\sue\projects\exercise\servlets;c:\J2EE1.4\lib;
c:\J2EE1.4\jdk\lib;c:\J2EE1.4\jdk\jre\lib;

The first path is my working directory. The compilation error is package javax.servlet does not exist; package javax.servlet.http does not exist; It also points at all other places where the servlet classes are used.

Where am i going wrong? Do I need to download something else?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With Tomcat, you don't need j2ee.
Don't know if it hurts but take it out for now.

Add TOMCAT_HOME/common/lib/servlet-api.jar to your classpath and try compiling.
Tomcat ships with the j2ee components it needs.

Let us know
 
Sue Pillai
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, it did compile after adding the classpath you mentioned.

The next question as you can guess is how to run the servlet on tomcat. I am used to javawebserver where we put the class files in servlets directory and htmls in public_html.

How does it work in tomcat? If it is complicated can somebody provide a link for a good read on how to run servlets on tomcat? Thanks again!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TOMCAT_HOME/webapps/YOUR_APP
TOMCAT_HOME/webapps/YOUR_APP/jsps, html, etc..
TOMCAT_HOME/webapps/YOUR_APP/WEB-INF/web.xml
TOMCAT_HOME/webapps/YOUR_APP/WEB-INF/classes/YOUR_PACKAGE/YOUR_CLASSES
TOMCAT_HOME/webapps/YOUR_APP/WEB-INF/lib/JAR_FILES..

It's covered here:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/index.html

Also, I've published some simple war file examples that you can download and run. The directory structures and web.xml files in them are correct.
http://simple.souther.us
[ February 10, 2005: Message edited by: Ben Souther ]
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sue,

You might find the following useful as well:

http://www.coreservlets.com/Apache-Tomcat-Tutorial/

And there are probably no better books on the subject of servlets/jsp (tutorial type) than Kathy Sierra and Bert Bates' book: http://www.amazon.com/exec/obidos/ASIN/0596005407/qid=1108089062/sr=2-1/ref=pd_ka_b_2_1/104-2470500-1671162
and Marty Hall's book:
http://www.coreservlets.com/#CWP2

Also check out:


Hope you find these helpful...

Mark
 
M Streit
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sue,

Meant to include: http://www.onjava.com/pub/a/onjava/2004/01/28/tomcat5.html

Mark
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
u can try the thing-----
compile like this way

javac -classpath c:\sun\appserver\lib\j2ee.jar;. name of the prog.java

may this will help u
gaurav
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic