This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding useBean

 
Deepak Bobal
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*******************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
 
Gopikrishna Kunisetty
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deepak,

Try with the complete class name i.e. packagename.classname
 
Deepak Bobal
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
Java Monad Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Move the 'Emp' class into a seperate file 'Emp.java' and make the class as 'public'.
 
Deepak Bobal
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Marimuthu

it works....
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic