This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have created a Simple Bean class. The class is not in a package. When i tried using it . I got the error that "Class not found". But the same is working after bring it in a package. Will the bean work without package. Arun
Bosun is correct, but this is really a bug in Tomcat. The Tomcat (Jasper) JSP container generates servlet source code for your JSP. As part of this, it generates a "package" statement at the top, one that maps to your directory structure. However, this means if you use an unqualified class name in the code anywhere, it is assumed to be either (1) part of the same package as the generated JSP, or (2) found in the import list. Since your bean is neither, you get a compilation error. There is an easy workaround, however. You can explicitly specify your bean in a page import directive: <%@ page import="MyBean" %> ... <jsp:useBean id="x" class="MyBean"/> It's a little easier to see what I mean if you look at the generated servlet source code in your Tomcat/work directory. I would emphasize again that this restriction is not part of the JSP specification, it is a Tomcat bug. JRun 3.0 has no such problem, for example, because it doesn't create a package statement. ------------------ Phil Hanna Sun Certified Programmer for the Java 2 Platform Author of : JSP: The Complete Reference Instant Java Servlets Website: http://www.philhanna.com
Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Joined: Apr 05, 2001
Hi, Thanks Phil, I got ur Point. May be i'll use JRun in case needed. Regards Arun