Hi,
 
    In order to access the class (bean), the class should be available in the classpath set for the JSP Engine or your web server container. First, check whether classpath is set properly (classpath should be set to the parent directory of hellopackage) and secondly check whether the .class file is available in the hellopackage directory. I Tested it on IIS with Servlet Exec. It is working fine. Two more errors are there - 1. property should be equal to "*" without any space. 2. request.getParamater should be request.getParameter.
 
Hope it helps,
Mohan.
-----Original Message-----
From: chenghong [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 20, 2001 11:28 PM
To: [EMAIL PROTECTED]
Subject: Re: how to access java classes from jsp

i think the rule of bean in java is that your constructor must be empty. meaning
public hello(){
 // emtpy
}
 
correct me if i am wrong
 
----- 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