permaculture playing cards
The moose likes Servlets and the fly likes Java Beans error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Java Beans error" Watch "Java Beans error" New topic

Java Beans error

Shuaib Gill
Ranch Hand

Joined: May 29, 2001
Posts: 62
I'm trying to seperate the presentation from business logic in my test application. I am getting a "The property doesn't exsist" error from my browser. Here is my html form:
<title>User Info Entry Form</title>
<body bgcolor="white">
<form action="userinfo2.jsp" method="post">
<td><input type="text" name="username" >

<td><input type="text" name="job">

<td>Some text:</td>
<td><input type="text" name="sometext" >

<td colspan=2><input type="submit"></td>
Here is my jsp page, which the form above is calling:
<%@ page import="UserBean"%>
<%@ page language="java" contentType="text/html" %>
<jsp:useBean id="userData" class="UserBean" >
<jsp:setProperty name="userData" property="*" />
This is what is saved...
<li>User name : <jsp:getProperty name="userData" property="username" />
<li>Occupation : <jsp:getProperty name="userData" property="job"/>
<li>some text : <jsp:getProperty name="userData" property="sometext" />
And here is the UserBean, can someone explain to me why I'm not getting the desired result?
import java.util.*;
// import java.sql.*;
public class UserBean// JavaBean example
private String username;
private String job;
private String sometext;
// public UserBean{}
public void setUsername (String username)
public void setJob (String job)
public void setSometext (String sometext)
public String getUsername()
return username;
public String getJob()
return job;
public String getSometext()
return sometext;
Why do I get that error?

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13035
You need to put your Bean in a package, (say com.mypackage) then:
<%@ page import="com.mypackage"%>
<jsp:useBean id="userData" class="com.mypackage.UserBean" >
Of course your class code should go in the correct directory for your web application
...+--- WEB-INF
..........+--- classes
JSP has a hard time figuring out what to do if the bean is not in a package.

[This message has been edited by William Brogden (edited June 19, 2001).]
I agree. Here's the link:
subject: Java Beans error
jQuery in Action, 3rd edition