File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes unable  to compile servlet  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

unable to compile servlet

shailendra shrivastava
Greenhorn

Joined: Nov 16, 2004
Posts: 5
when i try compling the servlet then i get 6 error saying package
javax.servlet does not exists...


package mypackage;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;




public final class Hello extends HttpServlet {



public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {

response.setContentType("text/html");
PrintWriter pw = response.getWriter();

pw.println("<html>");
pw.println("<head>");
pw.println("<title>Sample Application Servlet Page</title>");
pw.println("</head>");
pw.println("<body bgcolor=white>");

pw.println("<table border=\"0\">");
pw.println("<tr>");
pw.println("<td>");
pw.println("<img src=\"images/tomcat.gif\">");
pw.println("</td>");
pw.println("<td>");
pw.println("<h1>Sample Application Servlet</h1>");
pw.println("This is the output of a servlet that is part of");
pw.println("the Hello, World application. It displays the");
pw.println("request headers from the request we are currently");
pw.println("processing.");
pw.println("</td>");
pw.println("</tr>");
pw.println("</table>");

pw.println("<table border=\"0\" width=\"100%\">");
Enumeration names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
pw.println("<tr>");
pw.println(" <th align=\"right\">" + name + ":</th>");
pw.println(" <td>" + request.getHeader(name) + "</td>");
pw.println("</tr>");
}
pw.println("</table>");

pw.println("</body>");
pw.println("</html>");

}


}
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You need to have the servlet JAR file on your classpath when you compile. This JAR is can be found somewhere in your application server path (for example, in Tomcat 5.5 it's in Tomcat\common\lib\servlet-api.jar), or you can download the J2EE SDK from Sun.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I was going to move this to the Servlet forum, since the question belonged there, but I see it's already posted there. Please do not post questions in multiple forums.

Closing this copy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable to compile servlet