• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error when compiling the servlet Page 81 of HFSJ

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

When I am trying to compile the servlet on page 81, I am getting the following error. Here are the details

D:\MyProjects\beerV1>C:\j2sdk1.4.2_04\bin\javac -classpath c:/Program*/Apache*/Tomcat*/common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java

output
*****************************************************************************
src/com/example/web/BeerSelect.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
src/com/example/web/BeerSelect.java:4: package javax.servlet.http does not exist import javax.servlet.http.*;
^
src/com/example/web/BeerSelect.java:7: cannot resolve symbol
symbol : class HttpServlet
location: class com.example.web.BeerSelect
public class BeerSelect extends HttpServlet{
^
src/com/example/web/BeerSelect.java:9: cannot resolve symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void dopost(HttpServletRequest request, HttpServletResponse response)
^
src/com/example/web/BeerSelect.java:9: cannot resolve symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
public void dopost(HttpServletRequest request, HttpServletResponse response)
^
src/com/example/web/BeerSelect.java:10: cannot resolve symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
throws IOException, ServletException {
^
6 errors
*****************************************************************************

I can understand that the compiler is unable to find the servlet api's. I have development environment set up on D drive and deployment environment set up on C drive.

Can someone help me?

Thank you,

Harish
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add servlet-api.jar to your class path. You can find this in $tomcat-home\common\lib directory.
 
reply
    Bookmark Topic Watch Topic
  • New Topic