"Huynh, Mai" wrote:

> Does the bean in jsp have to be in the same folder with it or in subfolder?
> For ex: <jsp:useBean id="firstBean" scope="request"
> class="beans.project1.firstBean" >
> My jsp page in in folder jsp\ , so does the beans need to be in that folder
> too?  If it is in different folder, how the server knows where it located?
>

Beans need not (and probably should not) be in the same folders as your JSP and
HTML pages.

Instead, the bean classes must be accessible on the classpath that is configured
for your engine.  In an environment compatible with the servlet 2.2 spec, there
is are reserved places that is automatically included:
* All JAR files in the "WEB-INF/lib" directory
* All unpacked class files in the "WEB-INF/classes" directory
For other versions, the rules for setting the classpath are specific to the
engine -- check the docs.

Note that when you are using packages ("beans.project1.firstBean"), your
directory structure needs to reflect that.  If you wanted to put this bean under
the classes subdirectory (rather than creating a JAR file), you would need to
put it at:

    WEB-INF/classes/beans/project1/firstBean.class

Craig

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to