*
The moose likes JSP and the fly likes jsp when compiled cant find bean class see code servlet exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp when compiled cant find bean class see code servlet exception" Watch "jsp when compiled cant find bean class see code servlet exception" New topic
Author

jsp when compiled cant find bean class see code servlet exception

Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
//here is my simple jsp page

<html>
<head>
<jsp:useBean class="stars.linebean" id="bean0" scope="page" />
<title>Access JavaBean Methods</title>
</head>
<body>
Welcome to my Web page
<%= bean0.doubleLine(30) %>
</body>
</html>

//here is my simple bean
package stars;
public class linebean
{
public String stars(int x)
{
String text = "<br>";
for(int i =0;i<x;i++)
text = text + "*";
return text + "<br>";
}

public String doubleLine(int x)
{
String text = "<br>";
for (int i=0;i<x;i++)
text = text + "=";
return text + "<br>";
}
}
this is in the correct path where i run the sample servlets
C:\jakarta-tomcat-4.0\webapps\examples\WEB-INF\classes\stars
inside stars is the linebean.class

//3 errors occur
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 4 in the jsp file: /jspbean.jsp
Generated servlet error:
C:\jakarta-tomcat-4.0\work\localhost\FortKnox\jspbean$jsp.java:60: Class stars.linebean not found.
stars.linebean bean0 = null;
^

An error occurred at line: 4 in the jsp file: /jspbean.jsp
Generated servlet error:
C:\jakarta-tomcat-4.0\work\localhost\FortKnox\jspbean$jsp.java:63: Class stars.linebean not found.
bean0= (stars.linebean)
^

An error occurred at line: 4 in the jsp file: /jspbean.jsp
Generated servlet error:
C:\jakarta-tomcat-4.0\work\localhost\FortKnox\jspbean$jsp.java:68: Class stars.linebean not found.
bean0 = (stars.linebean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "stars.linebean");
^
3 errors
any help greatly appreciated
Ray Smilgius

------------------
Sun Certified Java Programmer
Sun Certified Java Developer
I-Net Certified
A+ Certified
Network+ Certified
MCP
[This message has been edited by Ray Smilgius (edited November 19, 2001).]


SCJO, SCJD, SCWCD, I-Net+, A+, Network+, MCSD, MCDBA, MCP, MCT
alex almero
Greenhorn

Joined: Jul 19, 2001
Posts: 6
u need to add a page attribute and import ur class, see sample below
<%@page language="java" import="java.util.*,keic.common.util.*,keic.accept.longterm.info.*" contentType="text/html;%>

best regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp when compiled cant find bean class see code servlet exception
 
Similar Threads
404 error on calling my servlet
trying to get a simple bean example to work using Tomcat and jsp
Problem with jsp finding my bean see code
is this web.xml correct
Problem with simple bean that fails only at deployment location