jsp and usebeans

F

focode

i am implementing java beans with jsp and tomact returns the following
error

org.apache.jasper.JasperException: Unable to compile class for JSP:



An error occurred at line: 4 in the jsp file: /EmployeeBean.js


An error occurred at line: 4 in the jsp file: /EmployeeBean.jsp
EmployeeBean cannot be resolved to a type
1: <HTML>
2: <HEAD>
3: <TITLE>Example: Simple Java Bean</TITLE>
4: <jsp:useBean id="EmployeeBean" scope="page"
5: class="EmployeeBean" />
6: </HEAD>
7:


An error occurred at line: 21 in the jsp file: /EmployeeBean.jsp
EmployeeBean cannot be resolved to a type
18:
19: <%-- Get bean properties --%>
20: <P>
21: <jsp:getProperty name="EmployeeBean" property="fullName" />
22: </P>
23:
24: </BODY>

the programs are listed below

the java program...


public class EmployeeBean
{
private String firstName = "";
private String lastName = "";

//First Name property
public void setFirstName(String name)
{
firstName = name;
}

public String getFirstName()
{
return firstName;
}


//Last Name Property
public void setLastName(String name)
{
lastName = name;
}

public String getLastName()
{
return lastName;
}

//Full Name Property - Read Only
public String getFullName()
{
return firstName + " " + lastName;
}
}


the jsp file is this...

<HTML>
<HEAD>
<TITLE>Example: Simple Java Bean</TITLE>
<jsp:useBean id="EmployeeBean" scope="page"
class="EmployeeBean" />
</HEAD>

<BODY>
<%
String last = "Burns";
%>

<%-- Set bean properties --%>
<jsp:setProperty name="EmployeeBean" property="firstName"
value="Robert" />
<jsp:setProperty name="EmployeeBean" property="lastName"
value="<%=last%>" />

<%-- Get bean properties --%>
<P>
<jsp:getProperty name="EmployeeBean" property="fullName" />
</P>

</BODY>
</HTML>

i have stored the class file in WEB-INF/classes folder


can any tell whats wrong ....
 
A

Arne Vajhøj

focode said:
i am implementing java beans with jsp and tomact returns the following
error

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 4 in the jsp file: /EmployeeBean.js

An error occurred at line: 4 in the jsp file: /EmployeeBean.jsp
EmployeeBean cannot be resolved to a type
1: <HTML>
2: <HEAD>
3: <TITLE>Example: Simple Java Bean</TITLE>
4: <jsp:useBean id="EmployeeBean" scope="page"
5: class="EmployeeBean" />
6: </HEAD>
7:

An error occurred at line: 21 in the jsp file: /EmployeeBean.jsp
EmployeeBean cannot be resolved to a type
18:
19: <%-- Get bean properties --%>
20: <P>
21: <jsp:getProperty name="EmployeeBean" property="fullName" />
22: </P>
23:
24: </BODY>

the programs are listed below

the java program...


public class EmployeeBean
{
private String firstName = "";
private String lastName = "";

//First Name property
public void setFirstName(String name)
{
firstName = name;
}

public String getFirstName()
{
return firstName;
}


//Last Name Property
public void setLastName(String name)
{
lastName = name;
}

public String getLastName()
{
return lastName;
}

//Full Name Property - Read Only
public String getFullName()
{
return firstName + " " + lastName;
}
}


the jsp file is this...

<HTML>
<HEAD>
<TITLE>Example: Simple Java Bean</TITLE>
<jsp:useBean id="EmployeeBean" scope="page"
class="EmployeeBean" />
</HEAD>

<BODY>
<%
String last = "Burns";
%>

<%-- Set bean properties --%>
<jsp:setProperty name="EmployeeBean" property="firstName"
value="Robert" />
<jsp:setProperty name="EmployeeBean" property="lastName"
value="<%=last%>" />

<%-- Get bean properties --%>
<P>
<jsp:getProperty name="EmployeeBean" property="fullName" />
</P>

</BODY>
</HTML>

i have stored the class file in WEB-INF/classes folder

can any tell whats wrong ....

Put the Java class in a package.

JSP pages have problems finding classes in default package.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,297
Latest member
EngineerD

Latest Threads

Top