• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What's wrong with my import declaration?

 
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's wrong with the import declaration in my JSP below? Tomcat complains that "The import AddressBean cannot be resolved".

Contents of webapps\beanTest\address.jsp:

<%@ page import="AddressBean" %>

<html>
<body>
</body>
</html>


The AddressBean class is located in webapps\beanTest\classes

The translated servlet code looks ok to me. It has this line:

import AddressBean;
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Edmund,

Try placing AddressBean inside a package for instance WEB-INF\classes\com\bean\AddressBean.class.
 
Edmund Yong
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

It is very strange, for the following two reasons:

(1) It works if I have package for the AddressBean class. If I don't have package like my original code, there will be compilation error.

(2) The following will not work. Tomcat complains that "The value for the useBean class attribute AddressBean is invalid."

<%@ page import="com.model.* " %>

<html>
<body>
<jsp:useBean id="address" class="AddressBean" scope="session" />
</body>
</html>

If I change the class attribute of <jsp:useBean> to "com.model.AddressBean", then it will compile without problems. It seems that the import is ignored.
 
author
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Edmund...

JDK 1.4 doesn't support the default package any more, and the JSP spec has come out in sympathy with this.

Take a look at JSP 11.2.

Best,

David.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic