I am finding problems using a simple Bean in a
JSP Page.
The bean code is given below:
public class HelloBean {
private
String name = "World";
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
I have placed the source code and the .class file in install_dir/webapps/ROOT/WEB-INF/classes directory
The JSP code is as under:
<%-- hello3.jsp --%>
<%@ page import="HelloBean" %>
<jsp:useBean id="hello" class="HelloBean">
<jsp:setProperty name="hello" property="*" />
</jsp:useBean>
<HTML>
<HEAD><TITLE>Hello</TITLE></HEAD>
<BODY>
<H1>
Hello, <jsp:getProperty name="hello" property="name" />
</H1>
</BODY>
</HTML>
I have placed the hello3.jsp file in install_dir/webapps/ROOT directory
Now when I try to run the JSP file using
http://localhost:8080/hello3.jsp , there is a compiler error indicating that the import statement is wrong. Where the Bean class file should be placed?
Regards,
Kunal Jaggi
SCJP2