aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Regarding useBean" Watch "Regarding useBean" New topic
Author

Regarding useBean

Deepak Bobal
Ranch Hand

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


<html>
<title>
useBean
</title>
<head>
<h1>
<center>
Getting Property Thru useBean
</center>
</h1>
</head>
<body bgcolor="#22eb9i">
<form action="Attri.do">
<center>
<br>
<br>
<input type="submit" value="Call The Servlet" >
</center>
</form>

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

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

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<servlet>
<servlet-name>Ch3_Beer1</servlet-name>
<servlet-class>Attri</servlet-class>
</servlet>

<servlet-mapping>

<servlet-name>Ch3_Beer1</servlet-name>
<url-pattern>/Attri.do</url-pattern>

</servlet-mapping>
</web-app>

***********************Attri.java***************//inside classes Directory


import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
class Emp
{
String name;
public String getName()
{
return name;
}
public void setName(String n)
{
this.name=n;
}
}

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

Emp e=new Emp();
e.setName("Deepak");
request.setAttribute("empName",e);
RequestDispatcher rd=request.getRequestDispatcher("Attribute.jsp");
rd.forward(request,response);
}
}

and

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

as

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 'Emp.java' 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: http://aspose.com/file-tools
 
subject: Regarding useBean