Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP can't find bean?  RSS feed

 
Lawrence Kennon
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working with an older version of ServletExec 3.1 (yes, very old, but it is what my production app uses so that is why I am working with it).

Am trying to get a JSP example from the book "Inside Servlets, 2nd Edition" to work. It uses a Java bean class (EmployeeBean.class) and no matter what I do so far I can't seem to get it to find the EmployeeBean.class. Always get an error like this when try to access the JSP that uses the bean:

/home/lkennon/servletexec/ServletExecAS/se-red1/ServletExecData/default/is/pagecompile/_ch18/_param_xjsp.java:26: Class pagecompile._ch18.EmployeeBean not found.
EmployeeBean employee = (EmployeeBean)pageContext.getAttribute( "employee" );

I have tried the following:

1. Placing the EmployeeBean.class directly in ServletExec's classpath in the StartServletExec script (this is on Linux).

2. Creating a EmployeeBean.jar file with the EmployeeBean.class in it and putting that in the WEB-INF/lib subdirectory for this web app.

3. Placing the EmployeeBean.class file in the Servlets subdirectory.

Any ideas, suggestions?

Thanks!

lk
 
Lawrence Kennon
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the answer, and it seems so simple. Originally the EmployeeBean.java source did not specify a package name. Added a package name of "test" and put the EmployeeBean.class file under:

../WEB-INF/classes/test/EmployeeBean.class

and voila! it worked (once I specified the full class name with package in the JSP.

Not sure why that would work and without a package does not, but hey, I am happy, it works and I can continue to play with this.

lk
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason for this is well-covered in the JSP FAQ.
 
Lawrence Kennon
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! I see it in the FAQ now. I swear I did look at the FAQ first, but was probably in too big a hurry to see what was right there. Also I was working from examples in a book and wrongly assumed therefore they should work if I just got things configured right. In any case the exercise was useful for me and hopefully guarantees the lesson will stay in my memory for a while.

lk
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lawrence Kennon:
Thanks! I see it in the FAQ now. I swear I did look at the FAQ first, but was probably in too big a hurry to see what was right there. Also I was working from examples in a book and wrongly assumed therefore they should work if I just got things configured right. In any case the exercise was useful for me and hopefully guarantees the lesson will stay in my memory for a while.

lk


If it was an older book, they might have worked when it was written.
The JVM was tightened up in 1.4.1 to bring it closer to the original spec.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!