Hi All,

I will attempt to make my question as clear as possible, though I am
sure it will sound a little vague given the fact that I am completely
muddled right now. I am conducting a simple exercise to learn about
JSPs. I have a simple database table in MS Access with 1 'Invoice'
record which has a unique ID. I have an InvoiceBean class which
represents a record with the appropriate get/set methods for each field.
I also have an InvoiceRepository class which handles all database access
and has a 'getInvoice' method that accepts the ID(an int) as a parameter
and returns the correspoding record from my database as an InvoiceBean
object.

One of the columns in each record is 'status'.

The value of status for record in my table with the ID=1 is 'complete'

The code for my sample JSP page that interacts with these is as follows:

<%@ page import='sample.invoice.*' %>
<html>
<head>
<jsp:useBean id='invoice' class='InvoiceBean'/>
<jsp:setProperty name='invoice' property='status' value='pending'/>
<jsp:scriptlet> invoice = InvoiceRepository.getInstance().getInvoice(1);
</jsp:scriptlet> <!-- Here, I am attemtpting to initialise 'invoice' to
A new InvoiceBean object is retreived from the repository -->

<title>Simple Invoice JSP</title>
</head>

<body>
Status for this invoice number using a JSP/XML tag is <jsp:getProperty
name='invoice' property='status'/>
<br>
Status for this invoice number using a generic tag is <%=
invoice.getStatus() %>
</body>
</html>

This results in the following output:

Status for this invoice number using a JSP tag is pending
Status for this invoice number using a generic tag is complete

The output I expected with this code is:

Status for this invoice number using a JSP tag is complete
Status for this invoice number using a generic tag is complete

It's almost as if I am now dealing with two separate InvoiceBean objects
with the same 'name'
, one which can be accessed by using jsp:setProperty/jsp:getProperty
tags and another that can be accessed by directly calling the
appropriate 'get/set' method in a scriptlet.

I've tried this in Tomcat 3.2.2 and Resin 2.0.0 with the same result so
I'm sure it's something simple(hopefully) that I am doing wrong,
especially since I have NEVER used JSPs prior to this.

Thank you in advance,

Abhijit.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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