I have tried for several days to get my first bean working but it is not working.
Here is my jsp page called mypage.jsp located in
C:\jakarta-tomcat-4.1.27\webapps\examples\jsp\mypage.jsp
The Java Bean called HelperBean.java located in
C:\jakarta-tomcat-4.1.27\webapps\examples\WEB-INFO\classes
where I compiled it in DOS such as:
javac HelperBean.java and it worked.
When I pull up the mypage.jsp web page I get the following errors:
Please advise what I am doing wrong?
Here is my jsp page called mypage.jsp located in
C:\jakarta-tomcat-4.1.27\webapps\examples\jsp\mypage.jsp
Code:
<html>
<body>
<%@ page import="HelperBean" %><%-- tried it with and without this line but still not working --%>
<jsp:useBean id="myHelperBean" class="HelperBean">
</jsp:useBean>
<%
myHelperBean.setIntProperty(34);
myHelperBean.setStringProperty("itworks");
%>
Value of mydata is
<%= myHelperBean.getIntProperty() %><BR>
Value of string prop:
<%= myHelperBean.getStringProperty() %>
</body>
</html>
The Java Bean called HelperBean.java located in
C:\jakarta-tomcat-4.1.27\webapps\examples\WEB-INFO\classes
where I compiled it in DOS such as:
javac HelperBean.java and it worked.
Code:
public class HelperBean
{
private int intProperty = -1;
private String stringProperty = null;
public HelperBean() {}
public void setIntProperty(int value)
{
intProperty = value;
}
public int getIntProperty()
{
return intProperty;
}
public void setStringProperty(String value)
{
stringProperty = value;
}
public String getStringProperty()
{
return stringProperty;
}
}
When I pull up the mypage.jsp web page I get the following errors:
Code:
[javac] Compiling 1 source file
C:\jakarta-tomcat-4.1.27\work\Standalone\localhost\examples\jsp\mypage_jsp.java:42: cannot resolve symbol
symbol : class HelperBean
location: class org.apache.jsp.mypage_jsp
HelperBean myHelperBean = null;
^
An error occurred at line: 1 in the jsp file: /jsp/mypage.jsp
Generated servlet error:
C:\jakarta-tomcat-4.1.27\work\Standalone\localhost\examples\jsp\mypage_jsp.java:44: cannot resolve symbol
symbol : class HelperBean
location: class org.apache.jsp.mypage_jsp
myHelperBean = (HelperBean) pageContext.getAttribute("myHelperBean", PageContext.PAGE_SCOPE);
^
An error occurred at line: 1 in the jsp file: /jsp/mypage.jsp
Generated servlet error:
C:\jakarta-tomcat-4.1.27\work\Standalone\localhost\examples\jsp\mypage_jsp.java:47: cannot resolve symbol
symbol : class HelperBean
location: class org.apache.jsp.mypage_jsp
myHelperBean = (HelperBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "HelperBean");
^
3 errors
Please advise what I am doing wrong?