File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp:useBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jsp:useBean" Watch "jsp:useBean" New topic


S Subramonyan
Ranch Hand

Joined: Aug 26, 2004
Posts: 52
I have an html addressForm.html calling address.jsp, on submitting the form.
In address.jsp, I use the bean AddressBean to capture the form variables into an object of type AddressBean.

Path of the files relative to document root:
addressForm.html: /

I get "unable to complile jsp file" error.

symbol : class AddressBean
location: class org.apache.jsp.address_jsp
AddressBean address = null;

Heres the code:

Please give your address: <br>
<form action = "address.jsp" >
Street: <input type="text" name="street"><br>
City:<input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Zip: <input type="text" name="zip"><br>
<input type="submit">

<%@ page import="AddressBean" %>
<jsp:useBean id="address" class="AddressBean" scope="session"/>
<jsp:setProperty name="address" property="*" />


public class AddressBean

private String street;
private String city;
private String state;
private String zip;

public void setStreet(String street){ this.street = street; }
public void setCity(String city){ = city; }
public void setState(String state){ this.state = state; }
public void setZip(String zip){ = zip; }

public String getStreet(){ return this.street; }
public String getCity(){ return; }
public String getState(){ return this.state; }
public String getZip(){ return; }


Kathy Sierra
Cowgirl and Author

Joined: Oct 10, 2002
Posts: 1589
<%@ page import="AddressBean" %>

Hi there -- I only had a second to glance at this, but I think the import is the problem. AddressBean is the name of the class, but not the package, right? Try taking the page import out or your JSP, or better yet--put AddressBean in a package, and then import the actual package or fully-qualified name of the class. I think the compiler might be expecting to see a "." after "AddressBean", although the compiler error you got doesn't make that clear... What you're doing is a class import, but that doesn't work when the class is in the "default" no-name package.

I think...

S Subramonyan
Ranch Hand

Joined: Aug 26, 2004
Posts: 52
Hi Kathy,

That was perfect.

It worked!!... Thanks a lot.

Turns out Tomcat 4.1.2 has small problems with jdk 1.4... Like this one.
Anyway, your input helped a lot.
Thank you.
Philippe Maquet

Joined: Jun 02, 2003
Posts: 1872
Hi "S MS",

Welcome to JavaRanch!

Maybe you didn't notice our Naming Policy when you registered. Could you please change your displayed name to meet it? You can change it here. Thank you in advance.

Best regards,


PS: You posted the same message on the SCBCD forum. As positing same messages on multiple forums is not allowed, the one on SCBCD will be deleted.
Yorck Zhou

Joined: Jan 04, 2003
Posts: 22
Hi, gurus,
In the Tomcat 4.1, any Bean and Tag Handler should all be in a package to be used in a servlets or a JSP.

Is it a shortcome of the Tomcat?

----------------------------------<br />SCJP SCWCD<br />dive into EJB, drinking hot Java
I agree. Here's the link:
subject: jsp:useBean
jQuery in Action, 3rd edition