• 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

encountering problem in importing java bean

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
}
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"/>
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your bean must be in a non-default package for the container to find it. No package, no import.
 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic