aspose file tools*
The moose likes Servlets and the fly likes servlet compiling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet compiling" Watch "servlet compiling" New topic
Author

servlet compiling

chandu raja
Greenhorn

Joined: Jan 11, 2001
Posts: 18
Hi All,
I want to know how to compile servlets ..
I have installed TOMCAT 3.2.1 server, jsdk21-eal.win ( servlet development kit), already have jdk1.3.
I have tried to install ApacheJserv1.1.2 I couldn't find jsdk.jar file so I couldn't install it...
now with sdk 1.3 or j2ee 1.2 java compiler I cannot compile the .java servlet
could anyone help me or provide me steps to do it...I followed the steps about how to install TOMCAT and other stuff from
http://www.archive.coreservlets.com/
thanks
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Since Servlet is just another java program you don't have to do anything exatra. Just makesure your classpath is correct and the javax files are visible for successful compilation.
You just compile the java source file and move the .class file to <approot>\web-inf\classes directory. If the servelet is new, then you will have to edit the web.xml and add the <servlet> and <servlet-mapping> entries and restart tomcat.
Ajith


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

are you able to run tomcat and access the URI
http://localhost:8080
Also, are you familiar with the ant build tool...?
regds.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
If the servelet is new, then you will have to edit the web.xml and add the <servlet> and <servlet-mapping> entries and restart tomcat....
Ajith:
I have been using the ant build tool. But am interested in this
new method, could you pl. elaborate on this technique.
Okay I have a myServ.class file. Now I am in the webapps dir of tomcat, what should I do further?
Chandu, sorry for the intrusion, but a related qstn so I am posting it here. Hope you don't mind.
Thanks.
- satya
chandu raja
Greenhorn

Joined: Jan 11, 2001
Posts: 18
Thanks Madhav and Ajit,
1) Yep.. I can do http://localhost:8080/ and I can see the tomcat Index page..
2) No I dont know the ant build tools.
3) Now I am getting the same errors saying that... given that HiThere,java is my servlet's name ..
these are some of the errors I ma getting total I am getting 6 of this knid of errors...

HiThere.java:13: cannot resolve symbol
symbol : class HttpServlet
location: class HiThere
public class HiThere extends HttpServlet {
^
HiThere.java:14: cannot resolve symbol
symbol : class HttpServletRequest
location: class HiThere
public void doGet(HttpServletRequest request,

finally does the release play any important role...just curious.. Iam using jdk 1.0 standard edition
thanks
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

Iam using jdk 1.0 standard edition
I though you said you already have jdk 1.3 ???
Okay abt the error:
did you add all the jar files you find in the jsdk21
dir's to your classpath. Add them and then compile.
This should give you the .class file.
After that I am waiting on Ajith to elaborate......
I will elaborate on the ant toll later on. Lest learn
what Ajith can tell us first
Ajith knock knock ...........

Regds.
- satya
chandu raja
Greenhorn

Joined: Jan 11, 2001
Posts: 18
Ajith,
Thanks a million it worked.....
Thanks again
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Satya,
My method is not rocket science. You will need the ant tool if you need an elaborate compilation process like for example defining dependencies between classes, what needs to be compiled from scratch etc. Think of it as a make tool which did the compiling, linking and generating the exe with lot of options.
My method is simple and works best if you are just playing around with Servlets. Since Servlet spec says the .class files should be in the \web-inf\classes directory, no matter where your sourcefile is, once it is compiled just move the .class to the \web-inf\classes directory. And it works!! Afterall, what ant is doing is the samething. It too, compiles the sourcefiles and moves it to appropriate classes directory. IMO ant is an overkill for small Servlets that you just write to learn concepts.
Optionally, for simple Servlets, you can even write your source code in the \web-inf\classes directory so that when you compile, the .class file is right there and you don't have to manually move it!!
Hope that helps.
Ajith
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Ajith:
I am more interested in the directory hierarchy structure...
where should my \web-inf dir be?
is it under %TOMCAT_HOME%\webapps\myApplication
Also, whats up with the web.xml file and the server entry?
where do i find the web.xml file?
is it the %TOMCAT_HOME%\conf directory?
These are things I don't get. Also, TOmcat Deployment organisation Help mentions that we need to edit the server.xml file in the conf dir.
These are qstn I am confused with and Hence find the overkilling
easier.........
Any clues...
regds.
- satya
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Okay now I know what the problem is
Take a look at %TOMCAT_HOME%\doc\appdev\contents.html
This document has various sections under it such as installation, deployment etc. Read through ALL the documents and you will get the idea how the pieces fit together.
As always ask me if you have questions!
Good luck,
Ajith
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

hmmmmmmmm.........maybe I am not making myself clear....
I will email you specifically what I am looking for...
and trust me......I have been there and done that!
Actually thats' what I meant by the Tomcat help stuff
I was referring.....
thxs anyways.
regds.
- satya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet compiling