?
Solved

package javax.servlet.jsp does not exist error

Posted on 2005-04-23
16
Medium Priority
?
6,288 Views
Last Modified: 2007-11-27
hi!

I am having package javax.servlet.jsp does not exist error when I trying to compile this.

package moreservlets.tags;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import java.math.*;
import moreservlets.*;



public class SimplePrimeTag extends TagSupport {
  protected int len = 50;
 
  public int doStartTag() {
    try {
      JspWriter out = pageContext.getOut();
      BigInteger prime = Primes.nextPrime(Primes.random(len));
      out.print(prime);
    } catch(IOException ioe) {
      System.out.println("Error generating prime: " + ioe);
    }
    return(SKIP_BODY);
  }
}


I copied servlet.jar into \WEB-INF\lib, but same error.

.;C:\jakarta-tomcat-5.5.4\common/lib/servlet-api.jar; C:\jakarta-tomcat-5.5.4\common/lib/jsp-api.jar;C:\jakarta-tomcat-5.5.4\webapps\~dkim18\WEB-INF\classes

What is wrong?
0
Comment
Question by:dkim18
  • 6
  • 3
  • 3
  • +2
15 Comments
 
LVL 8

Expert Comment

by:koppcha
ID: 13852225
do you have j2ee.jar in your classpath?
Download j2eexxx from the sun and point to this jar in your classpath
0
 
LVL 11

Accepted Solution

by:
sompol_kiatkamolchai earned 300 total points
ID: 13852581
hello dkim18,

If you are in Windows platform, you may need to config classpath by using back slash.

.;C:\jakarta-tomcat-5.5.4\common/lib/servlet-api.jar; C:\jakarta-tomcat-5.5.4\common/lib/jsp-api.jar;C:\jakarta-tomcat-5.5.4\webapps\~dkim18\WEB-INF\classes

should be

.;C:\jakarta-tomcat-5.5.4\common\lib\servlet-api.jar; C:\jakarta-tomcat-5.5.4\common\lib\jsp-api.jar;C:\jakarta-tomcat-5.5.4\webapps\~dkim18\WEB-INF\classes


Hope this help,

sompol
0
 

Author Comment

by:dkim18
ID: 13852622
Thanks for your comments. I downloaded j2ee.jar and pointed to my classpath like this, but same error. I also corrected back slash.

.;C:\jakarta-tomcat-5.5.4\common\lib\servlet-api.jar; C:\jakarta-tomcat-5.5.4\common\lib\jsp-api.jar; C:\Sun\AppServer\lib\j2ee.jar C:\jakarta-tomcat-5.5.4\webapps\~dkim18\WEB-INF\classes
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:koppcha
ID: 13852640
just double check ; is missing after j2ee.jar
>C:\Sun\AppServer\lib\j2ee.jar C:\jakarta-tomcat-5.5.4\webapps\~dkim18\WEB-INF\classes

put semicolon
C:\Sun\AppServer\lib\j2ee.jar ;C:\jakarta-tomcat-5.5.4\webapps\~dkim18\WEB-INF\classes

and how are you setting the classpath through control panel-->Environment variables
0
 

Author Comment

by:dkim18
ID: 13852691
I put ; like this and setting the classpath through Environment variables...but didn't work(got same error.). I am using windows XP and I don't have restart. right?

.;C:\jakarta-tomcat-5.5.4\common\lib\servlet-api.jar; C:\jakarta-tomcat-5.5.4\common\lib\jsp-api.jar; C:\Sun\AppServer\lib\j2ee.jar; C:\jakarta-tomcat-5.5.4\webapps\~dkim18\WEB-INF\classes
0
 

Author Comment

by:dkim18
ID: 13852703
This is the error...

C:\jakarta-tomcat-5.5.4\webapps\~dkim18\WEB-INF\classes\moreservlets\tags>javac
RandomNumberTag.java
RandomNumberTag.java:3: package javax.servlet.jsp does not exist
import javax.servlet.jsp.*;
^
RandomNumberTag.java:4: package javax.servlet.jsp.tagext does not exist
import javax.servlet.jsp.tagext.*;
^
RandomNumberTag.java:9: cannot resolve symbol
symbol  : class TagSupport
location: class moreservlets.tags.RandomNumberTag
public class RandomNumberTag extends TagSupport {
                                     ^
RandomNumberTag.java:13: cannot resolve symbol
symbol  : class JspWriter
location: class moreservlets.tags.RandomNumberTag
      JspWriter out = pageContext.getOut();
      ^
RandomNumberTag.java:13: cannot resolve symbol
symbol  : variable pageContext
location: class moreservlets.tags.RandomNumberTag
      JspWriter out = pageContext.getOut();
                      ^
RandomNumberTag.java:20: cannot resolve symbol
symbol  : variable SKIP_BODY
location: class moreservlets.tags.RandomNumberTag
    return(SKIP_BODY);
           ^
6 errors
0
 
LVL 8

Expert Comment

by:koppcha
ID: 13852711
Hope you have opened new window to run the javac command?
Once you have changed the environment variables you have to open up new window and try to compile
0
 

Author Comment

by:dkim18
ID: 13852713
yes, I did.
0
 

Author Comment

by:dkim18
ID: 13852716
I even used TextPad, but same result.
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 13852900
Just a try.
Please make sure that .jar file contains javax.servlet.jsp by using WinZip or any archive tools
0
 

Author Comment

by:dkim18
ID: 13853180
I downloaded this.
Sun Java System Application Server Platform Edition 8 Update 1
from here.
http://java.sun.com/j2ee/1.4/download.html#sdk
and it was application file not .jar file.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13857589
Assuming you have downloaded Tomcat, just include

    servlet.jar

in your classpath...

You will find it in:  Tomcat/common/lib
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13857592
There is no need to download the entire J2ee sdk
0
 

Expert Comment

by:oxfordtdk
ID: 14405303
make sure your environment variable is named CLASSPATH and not CLASS_PATH
0
 
LVL 35

Expert Comment

by:TimYates
ID: 14606989
I think the original problem (re-reading this) was that there seem to be spaces in the classpath...

Not sure what to do with this question tho... sorry about that Venabili... ;-)

Hopefully someone else has a preference ;-)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Last month Marc Laliberte, WatchGuard’s Senior Threat Analyst, contributed reviewed the three major email authentication anti-phishing technology standards: SPF, DKIM, and DMARC. Learn more in part 2 of the series originally posted in Cyber Defense …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question