2 Replies Latest reply on May 26, 2005 9:57 PM by n kwok

    package javax.servlet.jsp does not exist

    n kwok Newbie

      I 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;
       }
      }








        • 1. Re: package javax.servlet.jsp does not exist
          Matthias Hoehne Newbie

          I had a similar error when i tried to deploy a simple JSP for JBoss in a Tomcat manner, means to extend the server.xml by a context-tag. The JSP has been transformed to a servlet but this servlet i've been not able to get it compiled automatically by JBoss, but only by hand with an appropriate classpath extension like ...jboss-4.0.1RC2\server\default\lib\javax.servlet.jar ...

          The point was that JBoss works obviously different than Tomcat although
          JBoss integrates Tomcat. No server.xml adaption is necessary but only a DOS box with

          jar cf HelloWorld.war WEB-INF jsp //... and some more directories you need ...

          copy HelloWorld.war ...\jboss-4.0.1RC2\server\default\deploy

          When JBoss is already started you can see some seconds later the deployment print out in the JBoss-start-window.

          My system variables are simply like this:

          JAVA_HOME=C:\j2sdk1.4.2_06
          CLASSPATH=C:\j2sdk1.4.2_06
          JBOSS_HOME=C:\J2EE\jboss-4.0.1RC2

          HTH

          • 2. Re: package javax.servlet.jsp does not exist
            n kwok Newbie

            Komo, thank you for your advice.

            After I have added the servlet.jar in my classpath, the mentioned problem was solved. My system variables now is set like this:

            JAVA_Home: c:\Program Files\Java\jdk1.5.0_01
            JBOSS_HOME: C:\jboss-4.0.0

            Path=c:\Program Files\Java\jdk1.5.0_01\bin

            Classpath=c;\ jboss-4.0.0\bin;C:\jboss-4.0.0\server\default\lib\servlet.jar

            nkkwok