I didn't get a chance to read any messages in this thread except for the 2
included here.  I want to clarify something Anthony said so that nobody
thinks JSP is not ready.

One important part was left out of the example by Anthony.  The
<jsp:getProperty> tag is in a file that's <%@ include > by the file that
defines the bean.  See the following 3 files:

a.jsp:

<%@ page import="T" %>
<html>
<jsp:useBean id="hello" scope="session" class="T" />
<%@ include file="h.html" %>
</html>

h.html:

<jsp:getProperty name="hello" property="a" />

T.java:

public class T {
  public String getA() { return "A"; }
  public void setA(String a) { }
}

When running under WebLogic 4.5.1, it gives an exception complaining about
"hello is not defined as a bean".  Basically, the parser parses the included
file before it's merged with the main file, and it doesn't remember any
declaration in the main file either.  I should point out that
<jsp:getProperty> works fine when used in the main file.  The same 3 files
run fine in Orion server as well.  It appears to be a bug in WebLogic 4.5.1.
I have reported the bug.

As for the two tags, I'd like to point out that <jsp:getProperty> gives you
a language independent way of using beans.  Tool vendors will be putting out
tools to support this tag.  Imagine a page designer being able to drag and
drop a bean onto the page.  That's where to power lies.  The quotes don't
really need to be escaped to work properly, although they may mess up some
HTML editors.  That, is a tool problem, not a problem with JSP.

Jun Ying
[EMAIL PROTECTED]



-----Original Message-----
From: Bisong, Anthony (PS, IT)
Sent: Monday, December 06, 1999 4:26 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: Ying, Jun (PS, IT)
Subject: RE: Value of <jsp:getProperty.../> vs <%= ... %> ?


I completely agree with you D.J. Hagberg.  In my situation I defined the
following code below (I am using weblogic 4.51):

<jsp:useBean id="user" scope="session" class="com.logo.Mybean" />
...
<td bgcolor="<jsp:getProperty name="user" property="companyColor" />"
colspan="3">
...

And I got the following error message:  "user is not defined as bean"

I then used the escape character in the code like this:
...
<td bgcolor="<jsp:getProperty name=\"user\" property=\"companyColor\" />"
colspan="3">
...

I then see 'colspan="3">' appearing on the web page.

But when I use the code below it works fine:
<td bgcolor="<%= user.getCompanyColor() %> colspan="3">

My conclusion is that <jsp:getProperty ... /> messes up your HTML Code.  Be
very careful when you use it.

-----Original Message-----
From: D. J. Hagberg [mailto:[EMAIL PROTECTED]]
Sent: Sunday, December 05, 1999 5:35 PM
To: [EMAIL PROTECTED]
Subject: Value of <jsp:getProperty.../> vs <%= ... %> ?


A quick question for those of you in the know...

Are there rules or guidelines for when one should use:

    <jsp:getProperty name="beanname" property="propname" />

versus when one should use:

    <%= beanname.getPropname() %>

Personally, I think the latter is *much* cleaner inside a tag like the
following as you avoid the ugly sets of nested quotes (that mess up most
html validators).

<INPUT TYPE="..." NAME="X" VALUE="<%= beanname.getPropname() %>">

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to