Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiler not finding methods in HTTPServletRequest and HTTPServletResponse

 
Andrea Patterson
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Eduardo Dela Rosa
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently, you've got problem with your classpath.

Can you echo and display the value of your %classpath% variable?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The CompilingServlets FAQ has information on setting up the classpath for servlet compilation.
 
Ganesh Chinni
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic