• 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

use of bean in jsp

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
i am facing a problum in using java bean in jsp.
i am sending the sample code here.
bean is:
package op;
import java.io.*;
class exam
{
String name;
exam(){};
public void setname(String r)
{
name=r;
}
public String getname()
{
return name;
}
}
this file is stored in my application's WEB-INF's classes's op folder.
i am using bean in jsp as
<jsp:useBean id="db" class="op.exam" scope="request"/>
.
.
but this gives the error "The value for the useBean class attribute 'op.exam' is invalid."
please help me.
thankx
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Simple clue would be just restart the Server and check again !!!
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A couple things:

1.) When posting more than a line or two of your code, wrap the code in a set of UBB Code tags. This will preserve your indenting and make your code much easier to read (usually resulting in more people reading it and, thus, more help).

2.) Use the standard Java naming/capitalization conventions.
Class names should start with a capital letter. Object variables for those classes should be spelled the same but start with a lower case letter. This makes it very easy for people reading your code to understand the difference between the two.

When you say "this file" is stored under WEB-INF/classes/op, what file do you mean? A source file (.java) or did you compile the bean class and put the .class file there?
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To qualify as a bean, your class must have a public constructor that takes no arguments.

Suggestions

make your class public
make the constructor for it public
And as Ben said, follow standard java coding conventions to make it easier for others to understand your code.

Cheers,
evnafets
reply
    Bookmark Topic Watch Topic
  • New Topic