Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
    Bookmark Topic Watch Topic
  • New Topic

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

 
Lakshman Kumar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Report post to moderator
The index.jsp is under "test" (My web application / Context).
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • 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 ().
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!