• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JSP import directive in TOMCAT

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
I am using tomcat 3.2 on local machine,in one of my jsp page I have directive <%@ page import = "java.util.ArrayList" %> when this page is accessed in the program, tomcat gave the message :
Unable to compile class for...Class java.util.ArrayList not found in import.
import java.util.ArrayList;
^
import java.util.ArrayList;
^
Can anybody give me some help on that?
Thanks in advance.
Mike


[This message has been edited by Mike Han (edited September 17, 2001).]
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you set JAVA_HOME to point to your JDK?

Sounds like a pathing issue.
 
Mike Han
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I have set the JAVA_HOME to point to my jdk1.3.In fact other JSP pages and servlets run well.But this error still take place.
[This message has been edited by Mike Han (edited September 17, 2001).]
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not completely sure how Tomcat resolves it's imports... the JAVA_HOME was a first guess.

java.util.ArrayList is only in the JDK since 1.2.

Do you have an older JDK (like 1.1.8) on your system, and if you do, is it in your system CLASSPATH , in front of JDK1.3?

The only thing I can think of is that it's finding java.util.* from an old JDK, and it doesn't find ArrayList. At that point, it won't look further in the CLASSPATH to your JDK1.3, so you'll get the Class Not Found in import error.
 
Mike Han
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mike,
Thanks for your explanation.
I do have jdk1.1.8 installed in the system, and it is in the classpath,and also,when I run jre in command prompt it shows the version is 1.1.8.
The path I set to JAVA_HOME is jdk1.3 which comes with JBUILDER4( a sub folder under jbuider4). Now my question is how should I set the classpath for JDK1.3?
Regards
Mike

[This message has been edited by Mike Han (edited September 18, 2001).]
 
Mike Han
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike

I rename the jdk1.1.8\lib\classes.zip in classpath to a name with another extension, my JSP works well.
So does it mean TOMCAT compiles JSPs with classes in classpath rather than in the path specified by JAVA_HOME?
Thank you again.
Mike Han
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When a compiler attempts an import, and it cannot resolve the classes with the libraries it inherently knows about (the standard java api libraries) it uses the 'class finding path', or 'classpath' to attempt a resolution of the import.

So for the import: if you have x.y.z, it turns that into x/y/z (or x\y\z) and prepends each entry in the classpath, until it can find the class.

I'm not very familiar with the JSP compiler and how it goes about resolving classes...

JAVA_HOME is (I think) only used by the startup scripts for Tomcat, so the jsp compiler may not use this variable at all.

Setting environment variables is quite different for each operating system, so however you set JAVA_HOME... that's the same way to change your CLASSPATH.

In Win9x, it's in autoexec.bat
In WinNT, it's right-click My Computer, Properties, Environment
In Win2k, it's right-click My Computer, Properties, Advanced, Environment Variables
In any UNIX type system, it's in a startup script somewhere.

As a side note, my system does not have a CLASSPATH variable at all, and I can get JSP imports to work. This is not a recommendation to blow away your CLASSPATH variable! Other programs may need it. But because I also use JBuilder (which sends CLASSPATH to javac as a parameter), I don't need a system CLASSPATH.

It seems that if it's present, the jsp compiler will use CLASSPATH, but if it's not present, it looks in JAVA_HOME? I'm really not too sure what steps the jsp compiler takes to find classes.

Try this: look at your PATH variable. In my path variable, I have d:\jdk131\bin

This means that anything that calls 'javac' will use the jdk1.3.1 compiler... because this compiler 'knows' where to find java.util.ArrayList without the help of CLASSPATH, perhaps that might solve the problem?
[This message has been edited by Mike Curwen (edited September 19, 2001).]
 
get schwifty. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic