aspose file tools*
The moose likes Servlets and the fly likes Compiler not finding methods in HTTPServletRequest and HTTPServletResponse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Compiler not finding methods in HTTPServletRequest and HTTPServletResponse" Watch "Compiler not finding methods in HTTPServletRequest and HTTPServletResponse" New topic
Author

Compiler not finding methods in HTTPServletRequest and HTTPServletResponse

Andrea Patterson
Greenhorn

Joined: Apr 14, 2006
Posts: 1
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

Joined: Apr 15, 2004
Posts: 25
Apparently, you've got problem with your classpath.

Can you echo and display the value of your %classpath% variable?


Eduardo dela Rosa<br />SCJP 1.4
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The CompilingServlets FAQ has information on setting up the classpath for servlet compilation.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ganesh Chinni
Greenhorn

Joined: Dec 30, 2005
Posts: 24
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
 
 
subject: Compiler not finding methods in HTTPServletRequest and HTTPServletResponse