• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can a class outsiad the ../WEB-INF/ call the class under ../WEB-INF/?

 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The HFSS said that the classes under the /myapp/WEB-INF/ can't be accessed directly.But I want to know that "can a class at the root of myapp import a class under the /myapp/WEB-INF/classes/"?

a java class outside the /WEB-INF/


Can the above code run correctly? (The class above may be a common class or an applet).
Thanks!!
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing should stop a program from linking to a jar file in WEB-INF\lib as long as that program is in the local system. Why dont you give it a try ?
 
Stary Kapec
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But I want to know that "can a class at the root of myapp import a class under the /myapp/WEB-INF/classes/"


Hi,

You cannot put your class files at the root of your application.
All classes should be placed under WEB-INF/classes directory.
You can have two different classes in different packages under classes dir,
and one can import another. Here normal rules are in use.


The HFSS said that the classes under the /myapp/WEB-INF/ can't be accessed directly.


Yes, but the above statement regards something else. Not classes but any content under WEB-INF cannot be accesed by the browser through a direct http request.
Such content is to be used only by your application componenents.
[ January 12, 2007: Message edited by: Jasiek Motyka ]
 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Meyers:
Nothing should stop a program from linking to a jar file in WEB-INF\lib as long as that program is in the local system. Why dont you give it a try ?


Thanks!Following your suggestion, I do :
I make the java_c package into a jar file (this package was in the WEB-INF/classes before, and here is another package will call a class from the java_c).
But when I use eclipse to make it into a jar file and put the jar into the WEB-INF/lib, it didn't work. There is always a exception that "the java_c/Caller class can't be found".
Why? Did I do something wrong?
 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jasiek Motyka:

You cannot put your class files at the root of your application.
All classes should be placed under WEB-INF/classes directory.
You can have two different classes in different packages under classes dir,
and one can import another. Here normal rules are in use.
[ January 12, 2007: Message edited by: Jasiek Motyka ]


I know the rules, but I think a applet class mustnot in the WEB-INF/,because it will be downloaded by client.Am I right?Thanks!
 
Kidd He
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think HFSS don't give any examples about WEB-INF/lib (except the two jars of JSTL).
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applet classes have nothing to do with web app classes. They run in different JVMs and can't reference one another. As far as the web app is concerned, applet classes are just files that are accessed by HTTP. As far as the applet is concerned, WEB-INF isn't accessible to it at all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic