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 pls help me in javabean usage in jsp(doubt) 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 "pls help me in javabean usage in jsp(doubt)" Watch "pls help me in javabean usage in jsp(doubt)" New topic

pls help me in javabean usage in jsp(doubt)

bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45
Hi All!

i created one bean named as data.i compiled and move class file in to web-inf/classes/data.class.

i created one html file in that one text field named as username(which is property name in bean also) and calling given jsp.


<%@ page import="data" %>

<jsp:useBean id="data" class="data">
<jsp:setProperty name="data" property="username" />

<jsp:getProperty name="data" property="username" />


but it showing error as

Generated servlet error:
C:\Tomcat 5.0\work\Catalina\localhost\servletDemo\org\apache\jsp\ '.' expected
import data;
1 error

pls help me to resolve this error.

Thanks and Regards
swarna dasa
Ranch Hand

Joined: Mar 15, 2007
Posts: 108
Did you have a package statement in your file?
If no, then your data class doesn't have a package (it has a default package)

Remove the line
<%@ page import="data" %>
and you should be fine.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1710

You need to import in the following way:
packagename.classname to import particular class OR
packagename.* to import all classes of the package.

only writing import packagename gives error while exception in the Servlet

So it data is a package you do like:
<%@ page import="data.*" %>


I agree. Here's the link:
subject: pls help me in javabean usage in jsp(doubt)
It's not a secret anymore!