Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp:getProperty not working

 
John Cogan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code in a jsp page:
<%=faq.getQuestion()%>
The expression prints out okay.
<jsp:getProperty name="faq" property="question"/>
But the getProperty which is suppose to be the equivalent, does nothing!
Any ideas why this should be?
See below for most of the code
<%@ page import="com.taglib.wdjsp.faqtool.*"
errorPage="error.jsp" %>
<jsp:useBean id="faq" class="com.taglib.wdjsp.faqtool.FaqBean" scope="request"/>
<%
FaqBean[] faqs = (FaqBean[])request.getAttribute("faqs");
%>
...
<tr><th colspan="2">FAQ Administration: Update Menu</th></tr>
<%
for (int i=0; i < faqs.length; i++) {
faq = faqs[i];
%>
<tr>
<td><input type="radio" name="id"
value='<%=faq.getID() %>'>
<%=faq.getID() %></td>
<td><%=faq.getQuestion()%> <jsp:getProperty name="faq" property="question"/>
</td>
</tr>
<% } %>
...
</form>
</html>
 
Kaustubh Patil
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see the way u are instatiating the bean. You are setting the scope as request, where as there is no object of the name "faq" in your request. The object that exists in the request is "faqs".
So a new object of name "faq" is formed and put in to the request, which probably has not set its question variable.
Please check this out.
-Kaustubh.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!