#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    181
    Rep Power
    13

    problem when use bean class with JSP


    I keep been class in mybean package in

    c:\tomcat\webapps\Root\Web-inf\classes\mybean\somebean.class

    and save jsp file in
    c:\tomcat\webapps\Root\jsp\sec1\test.jsp

    and I type url in http://localhost:8080/jsp/sec1/test.jsp

    This work correct. and all directory such as \Root\jsp, \Root\news, \Root\webboard must use \Root\Web-inf\classes\mybean to keep class file. I have 2 question

    1. When I not use package, in file somebean.java I delete line 1 (package mybean) and compile again. and I edit file test.jsp change from
    <jsp:useBean id="bean1" class="mybean.somebean" />
    to
    <jsp:useBean id="bean1" class="somebean" />

    When I run this jsp file. It has error Class org.apache.jsp.someclass not found

    I try to shutdown and restart Tomcat. but it has same error.

    2. When I put class file in
    c:\tomcat\webapps\Root\jsp\Web-inf\classes\mybean\somebeen.class
    or
    c:\tomcat\webapps\Root\jsp\sec1\Web-inf\classes\mybean\somebeen.class
    Why it not found class bean?

    Any help please?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    5
    Rep Power
    0
    This is the correct behavior. The package that a bean or other class is in is reflected in the folder hierarchy under the Web-inf/classes folder. If you don't want to use packages (though you should use them to group related classes and to protect the namespace of your application) you have to have your class in the classes folder.

    Also note that the WEB-INF hierarchy is unrelated to the folder structure under the Root level of your webapp so you shouldn't have additional WEB-INF folders.

IMN logo majestic logo threadwatch logo seochat tools logo