• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

encountering problem in importing java bean

 
Priya Sri
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we are getting compilation error in importing the java bean.
is there any error in the path we specified.
we got these errors
-----------------------------------------------------------------
org.apache.jasper.JasperException: Unable to compile class for JSP
at org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:500)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:150)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:195)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
----------------------------------------------------------------------
structure of directory is
webapps/ch03/welcome.jsp
web-inf/classes/ch03/Bean1.class
---------------------------------------------------------------
jsp file
---------------------------------------------------------------
<jsp:UseBean id="bean1" scope="request" class="Bean1">
</jsp:UseBean>
<jsp:setProperty name="bean1" property="*" />
<html>
<head>
<title>java welcome page </title>
</head>
<body>
<h1>jsp welcome page</h1>
<b>Name :</b><% =bean1.getName() %><br>
<b>AGe: </b><% =bean1.getAge() %><br>
</body>
</html>
Java Bean
--------------------------------------------------------------------
package ch03;
public class Bean1
{
private String name=null;
private String age=null;
public Bean1()
{
}
public String getName()
{
return name;
}
public void setName(String n)
{
name=n;
}
public String getAge()
9{
return age;
}
public void setAge(String ag)
{
age=ag;
}
}
 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of
<jsp:UseBean id="bean1" scope="request" class="Bean1">
</jsp:UseBean>
Try This
<jsp:UseBean id="bean1" scope="request" class="Bean1"/>
 
Vijay Vaddem
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
make sure that web-inf shoud be in caps and also u need to mention
the fully qualified path name while using the bean in JSP's....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your bean must be in a non-default package for the container to find it. No package, no import.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic