tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicolas S i l b e r z a h n" <NiSJ...@DigitalAirways.com>
Subject TR: Using Packages for Bean Classes
Date Mon, 02 Sep 2002 13:00:48 GMT
for your information...

N i c o l a s   S i l b e r z a h n

<100% Java, Mobile, Offline aware>Wapaka Browser for mobile development
(XHTML, WML)</100% Java, Mobile, Offline aware> www.Wapaka.com


-----Message d'origine-----
De : A mailing list about Java Server Pages specification and reference
[mailto:JSP-INTEREST@JAVA.SUN.COM]De la part de Hans Bergsten
Envoye : dimanche 1 septembre 2002 00:44
A : JSP-INTEREST@JAVA.SUN.COM
Objet : Re: Using Packages for Bean Classes


Nicolas S i l b e r z a h n wrote:
> Hans Bergsten, author of JavaServer Pages in its paper "Hans's Top Ten JSP
> Tips" (google it for URL)
> wrote:
>
>
>
> Using Packages for Bean Classes
>
> When you develop a bean to be used in a JSP page, I recommend that you
make
> it part
> of a named package. A Java class that does not use a package statement
ends
> up in the
> so-called unnamed package. The servlet class generated from the JSP page
is,
> however,
> typically assigned to a named package. If you try to refer to a class in
the
> unnamed
> package from a class in a named package, Java cannot find the class unless
> you use an
> import statement to import it. In a JSP page that means you must use both
a
> page
> directive to import the class, and the <jsp:useBean> action to make it
> available:
>
> <%@ page import="UserInfoBean" %>
> <jsp:useBean id="userInfo" class="UserInfoBean" />
>
> <<<<
>
> it seems it does not work anymore with Tomcat 4.1.9:
>
> F:\Tomcat 4.1.9\work\Standalone\localhost\ecomm\contact_jsp.java:11: '.'
> expected
> import UserInfoBean;
>                           ^
>
> How to write it now if I don't want my beans in a package?

This has nothing to do with Tomcat 4.1.x. It's due to a "correction" in
Sun's JDK 1.4.x, see Sun's Bug Parade:

<http://developer.java.sun.com/developer/bugParade/bugs/4361575.html>

Based on the comments there, it's breaking code in many places and is
a very unpopular change that I wasn't aware of until I saw your mail and
did some research. Your choices at this point is to use a different
compiler (e.g. Jikes or Sun's JDK 1.3.x) or place your beans in a
package (which I recommend no matter what).

Hans
--
Hans Bergsten           hans@gefionsoftware.com
Gefion Software         http://www.gefionsoftware.com
JavaServer Pages        http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto listserv@java.sun.com with body: "signoff
JSP-INTEREST".
For digest: mailto listserv@java.sun.com with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message