Hello,
 
Try this approach.
 
1.Ensure that the sytem classpath variable is correct and it contains the path upto 'hellopackage' directory, not upto hello
class.
2.. Set the action of the form.
 
Sandeep
 
 ----- Original Message -----
From: nadia
Sent: Friday, September 14, 2001 12:33 AM
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

Reply via email to