• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

HelloServlet can not compile  RSS feed

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear ranchers
I am just biggining the preparation for scwcd and when i try to compile the following code it gives compiler error; please help me:

this code is from the book:Java the complete reference 5th edition page 953 and the error says:


package javax.servlet does not exist
package javax.servlet.http does not exist
cannot find symbol
cannot find symbol class ServletRequest
cannot find symbol class ServletResponse
cannot find symbol class ServletException



 
Rancher
Posts: 1878
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
servlet specification is not a part of standard java. You need to set the classpath to servlet api library. Best thing is to use some ide(s) like netbeans,myeclipse etc.
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Swastik Dey wrote: Best thing is to use some ide(s) like netbeans,myeclipse etc.


No, it helps, but it's not the best thing to do. Because it means that you (I don't mean "you" of course) can't even compile a class file, so in my opinion, you are not qualified enough to pass SCWCD. Your suggestion about setting the servlet api library in the classpath is good. We have a FAQ about compiling servlets, here.
 
tehika danait
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
According to Swastik and Christophe, I set my CLASSPATH variable to: C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar
as the servlet-api is found at C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib in my computer.
Unfortunately it is not still compiling. the compiler which i am using is JCreator.
what else my be the problem or is there somethig wrong in setting my CLASSPATH?

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classpath has to be set in JCreator, but I don't know this editor, so I can't help you. Check your editor's documentation.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!