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
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

In JSP, how to import a java class-in-default_package ?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I have questions about import java class in JSP,like the following structure

test
|
|__WEB-INF
|
|__classes
|
|_ Dog.class

In classes directory,I put a java class named Dog.class,and I put a JSP file
in test directory,named index.jsp ,and In index.jsp called Dog class,but I
don't use "import",I think JSP can find it.

/*Dog.java*/
public class Dog{
String name;
public Dog(String a){
this.name=name;
}
public String getName(
return name;
}
}

But when I run index.jsp,it raised error:
cannot resolve symbol : class Dog
Then I copy hello class into test directory,it still raise above errors.

My questions are:
1.I want to know what default path which JSP use class
2.I don't want to use "package" in Dog.java, If I use import in JSP,how to
write this import statement?

Thanks in Advance.
 
Lakshman Kumar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
The structure is being displayed incorrectly as...

test
|
|__WEB-INF
|
|__classes
|
|_ Dog.class

Actually it is as follows... test-->WEB-INF-->classes-->Dog.class.

Thanks.
 
Lakshman Kumar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
The index.jsp is under "test" (My web application / Context).
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Welcome to JavaRanch.

Please do not post the same question multiple times. Let's continue the discussion in this duplicate thread.

For future reference, you can edit your posts by clicking the little paper&pen icon ().
 
After some pecan pie, you might want to cleanse your palatte with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
    Bookmark Topic Watch Topic
  • New Topic