| Author |
Compiling Servlets how to..
|
Raja Sagar Panamgipalli
Ranch Hand
Joined: Aug 13, 2003
Posts: 109
|
|
Hi Guys, i'm currently faced with problem of compiling the servlets ..can anyone help me how to compile and run servlets. my j2sdk1.4.2 is placed in c:\ ie..c:\j2sdk1.4.2 but this doesn't, by using javac compile my servlets. I use tomcat5.0 ..i've observed that the html files we write should be placed inside c:\tomcat5.0\webapps\servlets-examples . and .class files of servlet files in c:\tomcat5.0\webapps\servlets-examples\web-inf Is this correct ..i'm not able to check this out bcos..i cannot compile my servlet java file. As servlets are part of J2ee..i also have J2eesdk1.4 ..now please help with the classpath settings. Thank you very much... Regards Sagar.
|
SCJP 1.4<br />SCBCD 1.3
|
 |
Tim Baker
Ranch Hand
Joined: Oct 04, 2003
Posts: 541
|
|
you don't need to place everything in the tomcat examples directory, you can create your own context under /webapps to get your servlets running add servlet.jar from the tomcat installation to your classpath
|
Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
|
 |
Krishna Srinivasan
Ranch Hand
Joined: Jul 28, 2003
Posts: 1803
|
|
set classpath for servlet.jar file and then put all servlets into WEB-INF/classes directory. it will compile prop[erly. u create ur own context and make entry for context-path in server.xml. u work with ur own context.
|
Krishna Srinivasan
OCAJP Mock Questions
|
 |
Raja Sagar Panamgipalli
Ranch Hand
Joined: Aug 13, 2003
Posts: 109
|
|
Hi Guys, I'm glad you people showed up... I dont find servlets.jar in the Tomcat installation dir. there is servlet-api.jar can you plz tell where i can find this jar..i remember this as to be the case when using javawebserver and java servlet development kit2.0. thanks in advance.. Sagar
|
 |
Tim Baker
Ranch Hand
Joined: Oct 04, 2003
Posts: 541
|
|
|
yes they renamed it in tomcat 5, that one will work
|
 |
Raja Sagar Panamgipalli
Ranch Hand
Joined: Aug 13, 2003
Posts: 109
|
|
Hey Thanx Buddy.. I jus compiled successfully...but where should i place the .class file. Consider i have a ServletEx dir inside my tomcat webapps dir ie.. c:\tomcat 5.0\webapps\ServletEx\LoginServlet.java [br] then compiled it after setting the classpath. i.e..c:\tomcat 5.0\webapps\ServletEx\javac LoginServlet.java thus .class is now created. By doubt is.. should the .html and .class reside inside the same directory so as to access(that seems obvious) but i'm having a situation here... thanx buddy.. i hope i made a point there.. plz help. Sagar
|
 |
Raja Sagar Panamgipalli
Ranch Hand
Joined: Aug 13, 2003
Posts: 109
|
|
Its me again.. i just dont get it some how.let me put the code.. Login.html LoginServlet.java goes like this.. both these are saved inside C:\tomcat 5.0\webapps\ServletEx as it is supposed to be even the .class file is inside the same dir. now when i access http://localhost:8080/ServletEx/Login.html it displays the Login page accurately but ..when i fill the text area and click "submit" ..there is an error saying LoginServlet not found. Plz brief me .. thanx for being patient..
|
 |
Tim Baker
Ranch Hand
Joined: Oct 04, 2003
Posts: 541
|
|
the class files go in C:\tomcat 5.0\webapps\ServletEx\WEB-INF\classes also don't save your .java files in C:\tomcat 5.0\webapps\ServletEx keep them somewhere else safe and then copy only the .class files accross into tomcat
|
 |
 |
|
|
subject: Compiling Servlets how to..
|
|
|