• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Websphere and JSP using Beans

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to do a 'usebean' in my JSP page. I can't see quite how to get this to work in WSAD. In other servers, you put the Java file in the 'classes' right under the web-inf folder and the JSP page finds it.

How can I get my JSP page in WSAD to find my bean???

Best,
 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the problem you are havng is Webshpere-specific, I'm moving this along to the Websphere Forum.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you just add a Java class to the Web Project it will automatically link your source code to the /classes directory appropriately. I'd advise that you need to take a look at a good WSAD tutorial -- either my book (below) or one of the other fine books like Howard Kushner's or Gary Craig's.

Kyle
 
Bob Hendry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
Bob Hendry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your book looks pretty cool. I'll pick it up.

Your advice sort of worked. At design time, WSAD sees the bean. But not at run time. Looks like the classpath may be different between design and when it is deployed and 'run on server'. Does this sound right?

I'm starting to like WS... Been using caveman tools for the past eight years.
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the classpath should be automatically set. Would you mind posting the contents of your .classpath file? Also, what exception do you get at runtime, and where do you see it?

Kyle
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the classpath should be automatically set. Would you mind posting the contents of your .classpath file? Also, what exception do you get at runtime, and where do you see it?

Kyle
 
Bob Hendry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. Here's the classpath for the project. I had to remove the start and end tags to be able to post it.

?xml version="1.0" encoding="UTF-8"?
classpath
classpathentry kind="src" path="JavaSource"
classpathentry kind="var"
path="SERVERJDK_50_PLUGINDIR/jre/lib/rt.jar"
rootpath="SERVERJDK_SRCROOT" sourcepath="SERVERJDK_50_PLUGINDIR/src.jar"
classpathentry kind="var" path="WAS_50_PLUGINDIR/lib/j2ee.jar"
classpathentry kind="var" path="WAS_50_PLUGINDIR/lib/servletevent.jar"
classpathentry kind="var" path="WAS_50_PLUGINDIR/lib/ivjejb35.jar"
classpathentry kind="var" path="WAS_50_PLUGINDIR/lib/runtime.jar"
classpathentry kind="output" path="WebContent/WEB-INF/classes"
classpath


Error is in the browser:
Error 500: Unable to compile class for JSP An error occurred at line: 1 in the jsp file: /FirstBean.jsp Generated servlet error: C:\Documents and Settings\Administrator\My Documents\IBM\wsappdev51\workspace\.metadata\ (AND SO ON)


Like I said, it compiles fine. Here is the JSP Page:

jsp:useBean id = "theBean" class = "PopulateName" scope = "session"
HTML
BODY
FORM
theBean.populateName() within a scriptlet
FORM
BODY
HTML
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, from this it seems like it can't compile your JSP and that it's not the classpath that's at fault here. Is there a class not found error further down the runtime stack you haven't shown?

Also, you don't have any package qualifiers on your bean class. Did you just create it in the default package?

Kyle
 
Bob Hendry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If I put the bean in a package it works fine. Tx for your help. Now I can't find the JDBC-ODBC bridge. When I try to load it my bean throws a ClassNotFoundException

"java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver"

Funny thing is, the same code works on another WS machine. Any ideas would be welcome.

Best,

Bob...
[ May 20, 2004: Message edited by: Bob Hendry ]
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!