Dear Fellow Java/JSP developers:
I am trying to use the <jsp:useBean> tag in a jsp that displays the values from a javaBean that gets populated by another class.
<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import = "java.util.ArrayList"%>
<%@ page import = "java.util.Iterator"%>
<%@ page import = "salattimes.CalendarParse" %>
<%@ page import = "salattimes.Salat" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="test" scope="session" class="calendar.Time" />
<% CalendarParse sTime = new CalendarParse();
Time mytime = sTime.runExample();%>
<%=mytime.getA() %>
<%=mytime.getB() %>
<%=mytime.getC() %>
<%=mytime.getD() %>
<%=mytime.getE() %>
</body>
</html>
However, up to now, I am only able to display the values on my JSP page using the scriptlet
<% CalendarParse sTime = new CalendarParse();
Time mytime = sTime.runExample();%>
to declare and create the object (the method call sTime.runExample(); populates the fields in the Java Bean), and the expressions:
<%=mytime.getA() %>
<%=mytime.getB() %>
<%=mytime.getC() %>
<%=mytime.getD() %>
<%=mytime.getE() %>
to present the values on the screen. What I would like to do is assign the object that I create to a javaBean reference declared in a <jsp:useBean> tag as follows:
<jsp:useBean id="test" scope="session" class="calendar.Time" />
<% CalendarParse sTime = new CalendarParse();
test = sTime.runExample();%>
and then present the values stored in the bean to the JSP page as follows:
<jsp:getProperty name="test" property="a" />
<jsp:getProperty name="test" property="b" />
<jsp:getProperty name="test" property="c" />
<jsp:getProperty name="test" property="d" />
<jsp:getProperty name="test" property="e" />
<jsp:getProperty name="test" property="f" />
Is this possible? When I try the above, I get "null" as my output on the screen. When I try the first approach listed above, I get the values I am looking for. Is there a way to accomplish this using the <jsp:useBean> approach?
Thanks to all those who reply.
Sincerely;
Fayyaz