Strange problem with Struts - Bean not found in any scope
Hi Guys,
I have been getting this strange error where I get a bean not found
error when I use <logic:iterate> . The issue
is that if I substitute the <logic:itearate> with a plain <% scriptlet
%> the JSP does not complain i.e It is able
the ArrayList in the session.
Can someone help ??
Here is my code
FacultyAction.java
-----------------------------
....
....
....
st.setId(rset.getString(1));
st.setName(rset.getString(2));
st.setSubject(rset.getString(3));
st.setQualification(rset.getString(4));
al.add(st);
}
if( count == 0 )
return mapping.findForward("failure");
HttpSession session = request.getSession(true); //
Create a new session
session.setAttribute("results", al);
.....
struts-config-faculty.xml
------------------------------------------<?xml version="1.0"
encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/
struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="fbean" type="app.FacultyBean" />
</form-beans>
<global-forwards/>
<action-mappings>
<action attribute="fbean"name="fbean"path="/faculty"
type="app.FacultyAction" >
<forward name="success" path="/faculty/faculty.jsp"
contextRelative="true" />
<forward name="failure" path="/faculty/failure.jsp"
contextRelative="true" />
</action>
</action-mappings>
</struts-config>
I have tried putting scope = "session" here but I get the same
problem.
---------------------------------------------------------------------------------------------------------------------------------------
faculty.jsp
----------------
.......
..........
Search Criteria For Faculty
</div><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:form action = "/faculty">
<table>
<tr>
<td>Faculty Id</td>
<td><html:text property="id"/></td>
<td><html:submit value="Send"/></td>
</tr>
</table>
</html:form>
<table border=1>
<tr>
<td>ID</td>
<td>Name</td>
<td>Subject</td>
<td>Qualification</td>
</tr>
<logic:iterate id="element" name="results" scope="session"
type="bean.Faculty" >
<tr>
<td><bean:write name="element" property="id" /></td>
<td><bean:write name="element" property="name" /></td>
<td><bean:write name="element" property="subject" /></td>
<td><bean:write name="element" property="qualification" /></
td>
</tr>
</logic:iterate>
</table>
Instead of the logic block if I put this stuff below , It works just
fine.
<%
ArrayList al = (ArrayList)session.getAttribute("result");
if(al != null)
{
%>
<tr>
<td>ID</td>
<td>Name</td>
<td>Subject</td>
<td>Qualification</td>
</tr>
<%
for(int i=0; i < al.size(); i++)
{
bean.Faculty st = (bean.Faculty)al.get(i);
%>
<tr>
<td><%= st.getId() %></td>
<td><%= st.getName() %></td>
<td><%= st.getSubject() %></td>
<td><%= st.getQualification() %></td>
</tr>
<%
}
}
%>
Please help. I have tried everything within my little knowledge.
Thanks