jsp when compiled cant find bean class see code servlet exception
Ray Smilgius
Ranch Hand
Joined: Jan 29, 2001
Posts: 120
posted
0
//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).]
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;%>