Just check to see that your class file is in the classpath.
Normally the class files lie in the WEB-INF/classes folder of your web
application.
----- Original Message -----
Sent: Friday, September 14, 2001 1:03
PM
Subject: how to access java classes from
jsp
Hi there all.
I have just started learning jsp and am not sure
how to access a class file from within a jsp page.
I have heard that it should be a Bean and u
access it by doing the following.
<jsp:useBean id="mybean"
scope="page"
class="hellopackage.Hello" />
<jsp:setProperty
name="mybean" property=" * " />
My problem is that I have created the following
bean..
package hellopackage;
public class Hello{
private String
username;
public Hello(){
username=null;
}
public void setUserName(String
name){
username=name;
}
public String getUsername(){
return
username;
}
}
and I am trying to access it with the folowing
page..
<%@ page
import="hellopackage.Hello"%>
<jsp:useBean id="mybean"
scope="page"
class="hellopackage.Hello" />
<jsp:setProperty
name="mybean" property=" * " />
<html>
<head><title>Hello,User</title></head>
<body bgcolor="#ffffff"
background>
<h1>What is your name ?</h1>
<form
method="get">
<input type="text" name="username"
size="25">
<br>
<input type="submit"
value="Submit">
<input type="reset"
value="Reset">
</form>
<% if(request.getParamater("username") !=
null){
%>
<%@ include file="response.jsp"
%>
<%
}
%>
</body>
</html>
I keep getting the following error
jsp:useBean can't find class
`hellopackage.Hello'
I am realy stuck cause how do u let the jsp see
the bean..
I have even tried putting the bean in a jar file
called hellopackage...
Pls help....
Thanking you all in
adavance