The moose likes Servlets and the fly likes Compile error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Compile error" Watch "Compile error" New topic
Author

Compile error

Vivek Gajabe
Greenhorn

Joined: Oct 15, 2008
Posts: 4
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Ch1Servlet extends HttpServlet{
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
/* some code */
}
}
*******************************
Error
1.package javax.servlet does not exist
import javax.servlet.*;
^
2.package javax.servlet.http does not exist
import javax.servlet.http.*;
^
3.cannot find symbol for class HttpServlet,class HttpServletRequest & class HttpServletResponse.

Please note that i have installed jdk 1.6,jre 1.6 & apache tomcat 6.0.Classpath is also set properly.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3035
    
    4

Originally posted by Vivek Gajabe:
Classpath is also set properly.


Incorrect. Your classpath should include the servlet-api.jar that comes with Apache Tomcat. It doesn't, which is why you get these errors.


Steve
Vivek Gajabe
Greenhorn

Joined: Oct 15, 2008
Posts: 4
Thanks a lot!!!
It's working. I have not included the jar file name in classpath, thats why it showed me an error.
Thanks!!!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Compile error
 
Similar Threads
error with compiling servlet
Why can't use javac to compile servlet?
Exception during compiling servlet
compilation error while running simple servlet code
How to solve this one