Hi all,
I happened to a strange problems.
The command prompt window display every bean id and question as expected from
database.
but the <jsp:getProperty name="faq" property="ID">
           <jsp:getProperty name="faq" property="question"> doesn't work,
it suppose look like
id       question
1        what's this
2       what's that

but now it look like
id
0
0

and also the bean property is id,why we need to put ID in <jsp:getProperty
name="faq" property="ID"> .

thank you all in advance

<%@ page import="com.taglib.wdjsp.faqtool.*"
errorPage="error.jsp" %>
<jsp:useBean id="faq" class="com.taglib.wdjsp.faqtool.FaqBean"/>
<%
  FaqBean[] faqs = (FaqBean[])request.getAttribute("faqs");
%>
<html>
<head><title>Update Menu</title></head>
<form name="menu" action="/webdev/servlet/FaqAdminServlet" method="post">
<table border="1" align="center"><tr><td>
<table bgcolor="tan" border="1" align="center" cellpadding="10"
cellspacing="0">
<tr><th colspan="2">FAQ Administration: Update Menu</th></tr>
<%
for (int i=0; i < faqs.length; i++) {
  faq = faqs[i];
%>
<% System.out.println(faq.getID()); %>
<% System.out.println(faq.getQuestion()); %>
<tr>
<td><input type="radio" name="id" value="<jsp:getProperty name="faq"
property="ID"/>">
<jsp:getProperty name="faq" property="ID"/></td>
<td><jsp:getProperty name="faq" property="question"/></td>
</tr>
<% } %>
<tr><td colspan=2 align="center">
<input type="submit" value="Abort Updating">
<input type="submit" value="Update Selected FAQ"
onClick="document.menu.cmd.value='update'">
</td></tr>
</table>
</td></tr></table>
<input type="hidden" name="cmd" value="abort">
</form>
</html>

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";
  }
}


Reply via email to