package javax.servlet.jsp does not exist
nkkwok May 10, 2005 12:15 AMI have encounter the following error when I compiled the Ex5AddTag.java which I put it under the following path:
C:\jboss-4.0.0\server\default\deploy\jsp.war\WEB-INF\classes
Error message:
Ex5AddTag.java:3: package javax.servlet.jsp does not exist
import javax.servlet.jsp.*;
Ex5AddTag.java:4: package javax.servlet.jsp.tagext does not exist
import javax.servlet.jsp.tagext.*;
Clearly, Java didn't find javax.servlet.jsp.* and import javax.servlet.jsp.tagext.*.
I understand that the javax.servlet package is not part of J2SE Java. I don't know how to get javac to use it and I don't know how to configure it to use include the javax.servlet .jar and the javax.servlet.jsp.tagext in my classpath.
I tried to add the following to my path, but it didn't work too:
C:\jboss-4.0.0\bin;C:\jboss-4.0.0\lib\servlet.jar;
Please advise and thanks in advance!
I checked that I have already have the following .jar files:
javax.servlet.jar
javax.servlet.jsp.jar
servlet.jar
C:\jboss-4.0.0\server\default\lib
My computer environment as shown:
****************
Operating system used: Window professional XP sp1 (English)
--------System >> Environment Variables >> User variables
ANT_HOME: C:\apache-ant-1.6.2
JAVA_Home: c:\Program Files\Java\jdk1.5.0_01
JBOSS_HOME: C:\jboss-4.0.0 Files\Java\jdk1.5.0_01\bin;C:\apache-ant-1.6.2\bin
--------System >> Environment Variables >> System variables
OS Windows_NT
Path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem; C:\Program Files\Common Files\Adaptec Shared\System; C:\Program Files\Microsoft SQL Server\80\Tools\Binn\; C:\Program Files\Java\jdk1.5.0_01\bin;C:\jboss-4.0.0\lib\servlet.jar;
PATHEXT:.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
For your easy reference, the code of Ex5AddTag.java:
package it350;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class Ex5AddTag extends TagSupport {
private int num1 = 0;
private int num2 = 0;
public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
out.print("The sum of " +
num1 + " and " +
num2 + " is " +
sum(num1, num2));
} catch (IOException e) {}
return (SKIP_BODY);
}
public void setNum1(int n1) {
num1 = n1;
}
public void setNum2(int n2) {
num2 = n2;
}
public int sum (int num1, int num2) {
return num1 + num2;
}
}