Servlet compilation error in j2sdk1.4.2_01

L

Len

HI;
I am stuck with the example code I downloaded from the JAva web site.
HelloServlet.java. Compiling with javac , and getting all errors about
not recognizing symbols. Like statement javax.servet.http.*; HttpServlet;doGet()
It seems the javax don't recognize any of this. I attached the code.
Thnks
Leon

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/** Simple servlet used to test server.
* <P>
* Taken from More Servlets and JavaServer Pages
* from Prentice Hall and Sun Microsystems Press,
* http://www.moreservlets.com/.
* &copy; 2002 Marty Hall; may be freely used or adapted.
*/

public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>Hello</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>Hello</H1>\n" +
"</BODY></HTML>");
}
}
 
S

secret

Could you post a print out of the error messages your seeing? It sounds
like a classpath problem.

alan
 
M

Marko Lahma

You need to have servlet.jar in you classpath in order for compilation
to work. For example javac -classpath ".;c:/servlet-lib/servlet.jar"
MyServlet.java

-Marko
 
L

Len

HI;
when I run HelloServlet.java with javac, the following error messages
appear.
Thnsk
Len

HelloServlet java:13 cannot resolve symbol
symbol class HttpServlet
location: calss HelloServlet
public class HelloServlet extends HttpServlet{

HelloServlet java:14 cannot resolve symbol
symbol class HttpServlet
location: calss HelloServlet
public void doGet(HttpServletRequest request)

HelloServlet java:15 cannot resolve symbol
symbol class HttpServlet
location: calss HelloServlet
HelloServlet Response response

HelloServlet java:16cannot resolve symbol
symbol class HttpServlet
location: calss HelloServlet
throws ServletException,IOException

another error message on Javax.server.htpp.*;

my autoexec.bat:
PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\j2sdk1.4.2_01\bin;"C:\ProgramFiles\Mts"
SET PATH=C:\Perl\bin;%PATH%
SET JAVA_HOME=C:\j2sdk1.4.2_01
SET PATH=%JAVA_HOME%\BIN;%PATH%;C:\PVSW\TANGO2~1;C:\PVSW\TANGO2~1\XML
SET CLASSPATH=.;C:\j2sdk1.4.2_01\LIB\TOOLS.JAR;C:\tomcat\tomcat\COMMON\LIB\SERVLET.JAR;C:\PVSW\TANGO2~1\BEANHA~1.JAR;C:\PVSW\TANGO2~1\JAVA
SET TOMCAT_HOME=C:\tomcat\tomcat
set pkware.ini=C:\pkware
 
M

Mark Meyer

In said:
HI;
when I run HelloServlet.java with javac, the following error messages
appear.
Thnsk
Len

HelloServlet java:13 cannot resolve symbol
symbol class HttpServlet
location: calss HelloServlet ^^^^^
public class HelloServlet extends HttpServlet{

HelloServlet java:14 cannot resolve symbol
symbol class HttpServlet
location: calss HelloServlet ^^^^^
public void doGet(HttpServletRequest request)

HelloServlet java:15 cannot resolve symbol
symbol class HttpServlet
location: calss HelloServlet ^^^^^
HelloServlet Response response

HelloServlet java:16cannot resolve symbol
symbol class HttpServlet
location: calss HelloServlet ^^^^^
throws ServletException,IOException

another error message on Javax.server.htpp.*;
^^^^^^^^^^^^^^^^^


I'd investigate the misspellings I've marked above. Strange that they
don't appear in the code you posted, though.


Mark Meyer (e-mail address removed)
Raytheon Voice (972)344-0830 Fax (972)344-6840
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top