aspose file tools*
The moose likes JSP and the fly likes use of bean in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "use of bean in jsp" Watch "use of bean in jsp" New topic
Author

use of bean in jsp

abhishek paliwal
Greenhorn

Joined: Jun 25, 2005
Posts: 4
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
Kalyana Sundaram
Ranch Hand

Joined: Mar 18, 2005
Posts: 94
A Simple clue would be just restart the Server and check again !!!


Only those who will risk going too far can possibly find out how far one can go !!!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use of bean in jsp
 
Similar Threads
bean:write query
javabean problem
bean problem
jsp:getProperty gives null
@ManagedBean Annotation JSF2