Missing JavaBean..

  • Thread starter Andrew Thompson
  • Start date
A

Andrew Thompson

My first (of many) dumb newbie questions while learning
JSP/Beans and other server side marvels relates to a page at..
http://www.lensescapes.com/tst/jsp/124 - accessbean.jsp

This page crashes while trying to access a JavaBean in the
same directory. There are two things I don't understand
about the page.

Why the "Note: sun.tools.javac.Main has been deprecated"
message - my bean doesn't have one, but I think that's
secondary to "Class _tst._jsp.LineBean not found"..

It looks as though it's looking in the tst/jsp directory for the
bean, which exists both there as well as WEB-INFO/classes,
the tst/jsp directory also has the source code of the (absolutely trivial)
bean.

The java code as well as the JSP saved as html are linked from
http://www.lensescapes.com/tst/jsp/accessbean.html

Can anybody clue me in as to how to get this simple
bean to work?

(scratches head) I'm very new to ServerSide stuff and not
sure of what is relevant so I better include more, rather than
less info, so..

I also have a series of JSP's in the http://www.lensescapes.com/tst/jsp/
directory, one of which is..
http://www.lensescapes.com/tst/jsp/110 - properties.jsp
This provides some further properties on the server environment.

Any help/pointers appreciated
 
A

Andy Flowers

The message "Note: sun.tools.javac.Main has been deprecated" is related to
your use of JDK 1.4. According to the Resin developers it is a harmless
warning and can be safely ignored.

As to your 'real' problem it appears that the LineBean is not declared to be
in the correct package, in fact from the source you have provided it's not
in any package. Either leave it with no package declaration and move the
..class file to the root of the WEB-INF\classes tree or put it into a
package.
 
A

Andrew Thompson

Andy Flowers said:
The message "Note: sun.tools.javac.Main has been deprecated" is related to
your use of JDK 1.4. According to the Resin developers it is a harmless
warning and can be safely ignored.

As to your 'real' problem it appears that the LineBean is not declared to be
in the correct package, in fact from the source you have provided it's not
in any package. Either leave it with no package declaration and move the
.class file to the root of the WEB-INF\classes tree or put it into a
package.

I've put a copy of the class in..
http://www.lensescapes.com/WEB-INFO/classes/LineBean.class
Is that where it needs to be put to be accessed in the JSP as
<jsp:useBean _class="LineBean"_ id="bean0" scope="page" />?

The exceptions on the page indicate the server is still looking in
tst/jsp/ for the class, or am I reading this wrong..
"Class _tst._jsp.LineBean not found"

??
 
A

Andy Flowers

It needs to be in WEB-INF\classes - not WEB-INFO

The _tst._jsp is just a reflection of the directory your JSP is in. The
compiler cannot find the .class file so is giving it's best stab error
message about where it might be looking for it.
 
W

Wendy S

Andrew Thompson said:
I've put a copy of the class in..
http://www.lensescapes.com/WEB-INFO/classes/LineBean.class
Is that where it needs to be put to be accessed in the JSP as
<jsp:useBean _class="LineBean"_ id="bean0" scope="page" />?

What are those underscores for?

Which JDK are you using? At some point in the recent past, Sun began
enforcing a rule which says you cannot import a class in the default package
[no package statement] into a class that is in a named package. If the
container is making up package names for the Servlets that your JSP's get
converted into, that may be why you can't import your bean class.

Production code needs to be packaged anyway, so you might try that and see
if it fixes this problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

javaBeans and JSP 2
JavaBean location question 0
JavaBean and BeanContext problem 0
2 domains off one host using JSP 3
JSP/JavaBean - Newbie help 1
about tomcat context 3
JS 0
jsp and usebeans 1

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top