Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compiling servlets

 
Naveed Ali
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
i am new to the servlets world. plz any body answer the following.
1. How to compile servlets from TextPade Or command line?
2. What are the requirements like JDK or JSDK, web server etc?
3. How to configure the relevant paths?
thnx.
Naveed
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All you need for compiling servlets is the latest sdk from Sun. You could also download the latest version of Jakarta's Tomcat to use as a servlet/jsp container. However, in order to run your servlet successfully, the directory structure that it is placed in has to comply with the servlet 2.3 specification.
Put your classes in a directory structure like this:
WebApplicationDirectory/WEB-INF/classes/com/yourHost/className
(com/yourHost refers to your classes package)
Put your deployment descriptor (web.xml file) like this:
WebApplicationDirectory/WEB-INF/web.xml
If you are using Tomcat, put your WebApplicationDirectory like this:
jakarta-tomcat-4.0.6-LE-jdk14\webapps\WebApplicationDirectory
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I heartily recommend the ANT tool for compiling servlets. It solves many annoying problems with classpaths by allowing you to define them in a build.xml file. Yes, ANT presents a bit of a learning curve, but you will be glad you did.
Personally I edit/manage servlet projects with UltraEdit-32 and have ANT configured as a tool that can be run from the editor.
Bill
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The initial post said that the guy was new to servlets and then William recommends learning Ant? Servlets present enough of a challenge to a newbie. Bad advice my friend.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bad advice my friend.

Completely disagree.
A more-than-trivial number of the questions in this forum, the JSP forum, and the Java in general forums are related to problems doing simple builds. Learning Ant is one of the best steps one can take when setting out to do anything non-trivial with Java -- including servlets.
bear
[ September 26, 2003: Message edited by: Bear Bibeault ]
 
Nischal Tanna
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry friend..dont misguide urself..
Download the latest jsdk version from the sun site..
for eg:jsdk2.0
before compiling a servlet program at the command line.
set the classpath as follows i have assumed jsdk2.0 folder in the e: drive)
>set classpath=e:\jdsk2.0\lib\servlet.jar;
Now u can compile the servlet as a normal javac command.
But remember that the class file has to be stored in the classes folder.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The initial post said that the guy was new to servlets and then William recommends learning Ant? Servlets present enough of a challenge to a newbie. Bad advice my friend.

I calls 'em like I sees 'em
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also remember that Tomcat doesnot use the System CLASSPATH while running.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic