• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pls help me in javabean usage in jsp(doubt)

 
bhaskaritp naidu
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

<html>
<body>

<%@ page import="data" %>


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


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


</jsp:useBean>
</body>
</html>

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
bhaskar.
 
swarna dasa
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
context.

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


Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic