• 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

Compiler not finding methods in HTTPServletRequest and HTTPServletResponse

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm doing the first project in the HeadFirst JSP & Servlets book. I'm getting the following errors when compiling a servlet:
C:\jakarta-tomcat-5.5.9\webapps\Beer-v1>javac -classpath %classpath% WEB-INF\src\com\Example\web\BeerSelect.java
WEB-INF\src\com\Example\web\BeerSelect.java:13: cannot find symbol
symbol : method setContentType(java.lang.String)
location: class javax.servlet.http.HttpServlet
response.setContentType("text/html");
^
WEB-INF\src\com\Example\web\BeerSelect.java:14: cannot find symbol
symbol : method getWriter()
location: class javax.servlet.http.HttpServlet
PrintWriter out = response.getWriter();
^
WEB-INF\src\com\Example\web\BeerSelect.java:16: cannot find symbol
symbol : method getParameter(java.lang.String)
location: class javax.servlet.http.HttpServlet
String c = request.getParameter("color");
^
3 errors
------------------------------------------------------------
Before I added the classpath I was getting errors that it couldn't find import files: javax.servlet.*; and javax.servlet.http.*;
Now it's not finding methods.
Has anyone experienced this problem?

Thanks,

Andrea
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apparently, you've got problem with your classpath.

Can you echo and display the value of your %classpath% variable?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The CompilingServlets FAQ has information on setting up the classpath for servlet compilation.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You can include servlet.jar in the classpath while compiling the Servlet classes using javac -classpath option.

For example, if your servlet name is ExampleServlet and if your servlet.jar is present in "/Users/Ganesh/" directory then to compile your servlet you can use the following command.

javac -classpath .:/Users/Ganesh/Servlet.jar ExampleServlet.java


If your servlet.jar is present in the same directory as the ExampleServlet then include ".:" in your classpath.


Regards,
Ganesh
SCJP 1.4
SCWCD 1.4
SCBCD 1.3
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic