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

Regarding useBean

Deepak Bobal
Ranch Hand

Joined: Feb 06, 2008
Posts: 96
*******************Attribute.jsp******************//inside MyUseBean Directory

Getting Property Thru useBean
<body bgcolor="#22eb9i">
<form action="">
<input type="submit" value="Call The Servlet" >

<!--Using Standard Action UseBean -->
<jsp:useBean id="empName" class="Emp" scope="request" />
Emp is :<jsp:getProperty name="empName" property="name" />

*************************Web.xml*******************//Inside WEB-INF Directory

<web-app xmlns=""





**************************************//inside classes Directory

import javax.servlet.*;
import javax.servlet.http.*;
class Emp
String name;
public String getName()
return name;
public void setName(String n)

public class Attri extends HttpServlet
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException

Emp e=new Emp();
RequestDispatcher rd=request.getRequestDispatcher("Attribute.jsp");


it's giving error

org.apache.jasper.JasperException: /Attribute.jsp(23,0) The value for the useBean class attribute Emp is invalid.

Even "Emp" class is properly placed in Directory structure..


C:\Tomcat 5.5\webapps\MyUseBean\WEB-INF\classes

why Emp file is not being located by Server

Thank You

Constant dripping hollows out a stone....
Gopikrishna Kunisetty
Ranch Hand

Joined: Jun 12, 2008
Posts: 35
Hi Deepak,

Try with the complete class name i.e. packagename.classname

- Krishna<br /> SCJP 1.4 SCWCD 5
Deepak Bobal
Ranch Hand

Joined: Feb 06, 2008
Posts: 96
Hi Krishna

But i am not keeping java file in Any package

it's directly in classes folder

even i tried ,u suggested me before my post

them also i was getting the same error..
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72

Move the 'Emp' class into a seperate file '' and make the class as 'public'.

- Marimuthu Madasamy
Deepak Bobal
Ranch Hand

Joined: Feb 06, 2008
Posts: 96
Thanks a lot Marimuthu

it works....
I agree. Here's the link:
subject: Regarding useBean
It's not a secret anymore!