• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp usebean action tag

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone...

I m trying to run 1 jsp program using action tag <jsp:usebean> and got following errors can any one just tell me what is this?

cannot find symbol
symbol : class studentsbean
location: class org.apache.jsp.beandemo_jsp
studentsbean student = null;
D:\ZALAK\NIIT_students\AdvancedJava_Programs\DemoUseBean\build\generated\src\org\apache\jsp\beandemo_jsp.java:55: cannot find symbol
symbol : class studentsbean
location: class org.apache.jsp.beandemo_jsp
student = (studentsbean) _jspx_page_context.getAttribute("student", PageContext.PAGE_SCOPE);
D:\ZALAK\NIIT_students\AdvancedJava_Programs\DemoUseBean\build\generated\src\org\apache\jsp\beandemo_jsp.java:57: cannot find symbol
symbol : class studentsbean
location: class org.apache.jsp.beandemo_jsp
student = new studentsbean();
D:\ZALAK\NIIT_students\AdvancedJava_Programs\DemoUseBean\build\generated\src\org\apache\jsp\beandemo_jsp.java:75: cannot find symbol
symbol : class studentsbean
location: class org.apache.jsp.beandemo_jsp
out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((studentsbean)_jspx_page_context.findAttribute("student")).getName())));
D:\ZALAK\NIIT_students\AdvancedJava_Programs\DemoUseBean\build\generated\src\org\apache\jsp\beandemo_jsp.java:81: cannot find symbol
symbol : class studentsbean
location: class org.apache.jsp.beandemo_jsp
out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((studentsbean)_jspx_page_context.findAttribute("student")).getAge())));
5 errors
D:\ZALAK\NIIT_students\AdvancedJava_Programs\DemoUseBean\nbproject\build-impl.xml:483: The following error occurred while executing this line:
D:\ZALAK\NIIT_students\AdvancedJava_Programs\DemoUseBean\nbproject\build-impl.xml:231: Compile failed; see the compiler error output for details.
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like the studentsbean Java Bean cannot be found, have you declared that class? Show us your JSP code (only the useBean declaration) and the studentsbean class. Also you have to reference the bean with its package, like:



By the way, normally classes are named camel case, in this case: public class StudentsBean.
 
zalak thakkar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok... my studentsbean.java class is like as below::



public class studentsbean
{
private String name = null;
private String email = null;
private int age = 0;

public String getName()
{
return name;
}
public String getEmail()
{
return email;
}
public int getAge()
{
return age;
}
public void setName(String name)
{
this.name = name;
}
public void setEmail(String email)
{
this.email = email;
}
public void setAge(int age)
{
this.age = age;
}
}
 
zalak thakkar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And my jsp page is as below::

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>BeanData.jsp</title>
</head>
<body>
<jsp:useBean id="student" class="studentsbean">
<jsp:setProperty name="student" property="name" />
<jsp:setProperty name="student" property="email" />
<jsp:setProperty name="student" property="age"/>
</jsp:useBean>
<h1> <u> STUDENT DATA : </u> </h1>
<p> Name : <i><jsp:getProperty name="student" property="name"/></i> </p>
<p> Email-ID : <i><%= student.getEmail() %></i> </p>
<p> Age : <i><jsp:getProperty name="student" property="age"/></i> </p>
</body>
</html>



Please help me....
 
zalak thakkar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya Albareto, it could not find my studentsbean class...
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's because you forgot to mention what package your studentsbean class was in. Look at Albareto's post again to see how to do that.

If you didn't put it in a package, that's a problem. Put it in a package.

(Also, while we're talking about naming conventions, if a bean is supposed to contain data about one student then "StudentsBean" is misleading. That leads me to believe that it contains information about students. A better name for a bean about one student would be "StudentBean".)
 
zalak thakkar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i have read that comment by Albareto, but my java class is in default package and it has no name..
 
Albareto McKenzie
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put it in a package and reference from the useBean with the complete package path as Paul suggested.

Edit, check this link, it is mandatory to have the Class in a package. It looks very much like your problem.
 
zalak thakkar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah,,it's working....Thank you so much - Albareto and Paul...:-)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic