aspose file tools*
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
Author

Java Beans error

Shuaib Gill
Ranch Hand

Joined: May 29, 2001
Posts: 62
Hi,
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:
<html>
<head>
<title>User Info Entry Form</title>
</head>
<body bgcolor="white">
<form action="userinfo2.jsp" method="post">
<table>
<tr>
<td>Name:</td>
<td><input type="text" name="username" >
</td>
</tr>

<tr>
<td>Occupation:</td>
<td><input type="text" name="job">
</td>
</tr>

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

<tr>
<td colspan=2><input type="submit"></td>
</tr>
</table>
</form>
</body>
</html>
Here is my jsp page, which the form above is calling:
<%@ page import="UserBean"%>
<%@ page language="java" contentType="text/html" %>
<html>
<body>
<jsp:useBean id="userData" class="UserBean" >
<jsp:setProperty name="userData" property="*" />
</jsp:useBean>
This is what is saved...
<ul>
<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" />
</ul>
</body>
</html>
And here is the UserBean, can someone explain to me why I'm not getting the desired result?
import java.io.*;
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)
{
this.username=username;
}
public void setJob (String job)
{
this.job=job;
}
public void setSometext (String sometext)
{
this.sometext=sometext;
}
public String getUsername()
{
return username;
}
public String getJob()
{
return job;
}
public String getSometext()
{
return sometext;
}
}
Why do I get that error?
Thanks,


programmer77
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
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
theapp
...+--- WEB-INF
..........+--- classes
.................+--com
......................+---mypackage
JSP has a hard time figuring out what to do if the bean is not in a package.
Bill

[This message has been edited by William Brogden (edited June 19, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Beans error