aspose file tools*
The moose likes Servlets and the fly likes unable t o compile the servlet .. plz help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "unable t o compile the servlet .. plz help" Watch "unable t o compile the servlet .. plz help" New topic
Author

unable t o compile the servlet .. plz help

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>");

}


}
Sarath Mohan
Ranch Hand

Joined: Mar 17, 2001
Posts: 213
put the servlet-api.jar in your classpath. It's available in tomcat jsp container


Sarath Mohan
Pavel Cherkashin
Ranch Hand

Joined: Mar 04, 2005
Posts: 47
Or you can use j2ee.jar from %J2EE_HOME%\lib directory if you have installed
j2ee-sdk-1.3.1 or other version. But the better way is to use server-native jar library


Pavel Cherkashin - <br />SCJP, SCWCD, SCDJWS, SCBCD, SCEA, ...<br />www.linkedin.com/in/pcherkas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable t o compile the servlet .. plz help