wood burning stoves 2.0*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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\first_jsp.java:6: '.' 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 data.java 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: 1707

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.*" %>


It is sorta covered in the JavaRanch Style Guide.
subject: pls help me in javabean usage in jsp(doubt)
Similar Threads
Error using beans and JSP
JSP and JavaBeans
unable to compile class for jsp
redirect a bean?