This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiling Servlets how to..

 
Raja Sagar Panamgipalli
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Krishna Srinivasan
Ranch Hand
Posts: 1862
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raja Sagar Panamgipalli
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes they renamed it in tomcat 5, that one will work
 
Raja Sagar Panamgipalli
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic