> <%@ 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 -->

I'll try to explain this and hopefully somebody corrects me if I get
some details wrong. You might need some knowledge about objects and
references/pointers to understand this.

One could say that the beans and the scriplet variables are in different
contexts. When you create a bean you automatically get a scriplet
variable with the same name.
Lets call them invoice[bean] and invoice[scriptlet]

  <jsp:useBean id='invoice' class='InvoiceBean'/>
  <jsp:setProperty name='invoice' property='status' value='pending'/>

After these two tags both the bean and the scriptlet variable references
the same object. You could say invoice[bean] = invoice[scriptlet] -> an
invoice which is pending.

  <% invoice = InvoiceRepository.getInstance().getInvoice(1); %>

This affects ONLY the SCRIPTLET variable. So, the scriptlet variable now
point at a different invoice!

  invoice[bean] -> an invoice which is pending.
  invoice[scriptlet] -> an invoice from the repository.

I believe that you can make the bean point at the same new object by
using:
  pageContext.setAttribute("invoice",invoice); // ("beanName", object)
(Anyone please correct me if I'm wrong).

Good luck.

  Mattias Jiderhamn
  Expert Systems
  [EMAIL PROTECTED]

===========================================================================
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