Hi,

Allow me to ask you a question, that I can not explain.  It seems that I really
miss out something with the jsp.   Here is my problem,  I have a simple jsp that
use java bean ( from a book example), however I narrow it down.   If I get the
value directly from bean through scriptlet, then it works fine as Method 1.
However, Method 2 does not work, I could not find what is wrong with it.   I
include here the jsp, the output, and java code for the bean.    Can you pls look
at the code below and tell me what I have done wrong there?  Thanks much for your
helps.


<%@ page import="com.taglib.wdjsp.faqtool.*"
errorPage="error.jsp" %>
<jsp:useBean id="faq" scope="page" class="com.taglib.wdjsp.faqtool.FaqBean"/>
<%
  FaqBean[] faqs = (FaqBean[])request.getAttribute("faqs");
%>
<html>
<%
for (int i=0; i < faqs.length; i++) {
  faq = faqs[i];
%>
<br>
Using method 1: <br>
Question is:  <%= faq.getQuestion() %> <br>
<br>
Using method 2: <br>
Question is: <jsp:getProperty name="faq" property="question" /> <br>
<br>
<% } %>
</html>
</jsp:useBean>


==================
Here is the output (you notice for method 2, the question is null)

Using method 1:
Question is: How can mode 1 format fracture files (.yaa) be converted to reticle
mode format?

Using method 2:
Question is:


Using method 1:
Question is: How can mode 2 format fracture files (.yaa) be converted to reticle
mode format?

Using method 2:
Question is:


=====================================
And the code for the bean is:

package com.taglib.wdjsp.faqtool;

import java.util.Date;

public class FaqBean {
  private int id;
  private String question;
  private String answer;
  private Date lastModified;

  public FaqBean() {
    this.id = 0;
    this.question = "";
    this.answer = "";
    this.lastModified = new Date();
  }

  public void setQuestion(String question) {
    this.question = question;
    this.lastModified = new Date();
  }

  public String getQuestion() {
    return this.question;
  }

  public void setAnswer(String answer) {
    this.answer = answer;
    this.lastModified = new Date();
  }

  public String getAnswer() {
    return this.answer;
  }

  public void setID(int id) {
    this.id = id;
  }

  public int getID() {
    return this.id;
  }

  public Date getLastModified() {
    return this.lastModified;
  }

  public void setLastModified(Date modified) {
    this.lastModified = modified;
  }

  public String toString() {
    return "[" + id + "] " + "Q: " + question + "; A: " +
      answer + "\n";
  }
}




==========
-TN

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to