problem when use bean class with JSP
I keep been class in mybean package in
and save jsp file in
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" />
<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
Why it not found class bean?
Any help please?
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.