This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem with visibility of interface class to implementation - JSP related Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem with visibility of interface class to implementation - JSP related" Watch "Problem with visibility of interface class to implementation - JSP related" New topic
Author

Problem with visibility of interface class to implementation - JSP related

Tyler Wright
Ranch Hand

Joined: Jun 25, 2009
Posts: 40
HI folks,

I am using tomcat as my servlet container.

I have an interface class Address and an implementation class AddressBean (both are located in):
"webapps/chapter14/WEB-INF/classes/web/Address.class and AddressBean.class"

I have a jsp in directory webapps/chapter14 which has the following jsp directive and action:
<%@ page import="web.*" %>
stuff...
<jsp:useBean id="address" type="web.Address" class="web.AddressBean" scope="session" />

I am using an empty web.xml (just has <web-app> </web-app>.

When I access the jsp that contains the useBean action with: "http://localhost:8080/chapter14/address.jsp"
the following error results:

An error occurred at line: 5 in the jsp file: /address.jsp
The type web.Address is not visible
2:
3:
4:
5: <jsp:useBean id='address' type='web.Address' class='web.AddressBean' scope='session'/>
6: <jsp:setProperty name='address' property='*' />
7:
8: <jsp:forward page="addressDisplay.jsp" >


Can anyone suggest to me why the JSP cannot locate the web.Address class.

Oh, if I remove the "type" attribute from the <jsp:useBean> action, it works fine...

thanks...


SCJP SCJD
Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 331
maybe you missed the package declaration in the interface, so it is unable to find such a class?


Blog
Tyler Wright
Ranch Hand

Joined: Jun 25, 2009
Posts: 40
Vishwanath Murthi wrote:maybe you missed the package declaration in the interface, so it is unable to find such a class?


I looked at that...both the interface and implementation class are in the package web. The two java files compiled fine using both Eclipse and javac...

10 min...pass...

OMG!
Actually, your idea made me go back and look more carefully at the interface...
The problem was so silly...I forgot to make the interface public...it was package scope only...what a stupid oversight...anyway, thank you Vishwanth...your comment was the key

Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 331
Cool, you got it...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with visibility of interface class to implementation - JSP related