Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

noob trying to run a simple servlet on his linux box

Status
Not open for further replies.

hugstable

Programmer
Joined
Feb 20, 2006
Messages
65
Location
US

trying to run the below code on my linux box:
Code:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
 
public class TestingServlet extends HttpServlet {
 
  public void doGet(HttpServletRequest request, 
    HttpServletResponse response) 
    throws ServletException, IOException {
    
    PrintWriter out = response.getWriter();
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>Servlet Testing</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("Welcome to the Servlet Testing Center");
    out.println("</BODY>");
    out.println("</HTML>");
  }
}


java version
Code:
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

when i compile i get
Code:
@skunkworks:/usr/lib/apache-tomcat/webapps/myApp/WEB-INF# javac Test*
TestingServlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
TestingServlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
TestingServlet.java:6: cannot find symbol
symbol: class HttpServlet
public class TestingServlet extends HttpServlet {
                                    ^
TestingServlet.java:8: cannot find symbol
symbol  : class HttpServletRequest
location: class TestingServlet
  public void doGet(HttpServletRequest request, 
                    ^
TestingServlet.java:9: cannot find symbol
symbol  : class HttpServletResponse
location: class TestingServlet
    HttpServletResponse response) 
    ^
TestingServlet.java:10: cannot find symbol
symbol  : class ServletException
location: class TestingServlet
    throws ServletException, IOException {
           ^
6 errors

new to this - pls help... also, did i enclude enough in the post from an info standpoint???
 
You need to inlcude the servlet-api.jar onto your CLASSPATH. Something like :

export TOMCAT_HOME=/usr/lib/apache-tomcat
export CLASSPATH=$CLASSPATH:$TOMCAT_HOME/common/lib/servlet-api.jar

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top