RE: Strange javabean problem

2002-02-25 Thread Greg Trasuk

Hi Rich:

Taglibs are a great idea.  Generally you want to keep your JSP's as
html-like as possible, which means you really should have no scripting
elements (i.e. embedded java code) in your JSP's.  Taglibs are one tool to
do this, pre-processing through a servlet is another tool.  Sometimes if I'm
in a hurry, I'll use 'include' functionality to achieve something similar.
There are also Model-View-Controller frameworks (like Struts) and template
engines (like Turbine), both of which have staunch followers on this list,
as well as lists of their own.

Greg Trasuk, President
StratusCom Manufacturing Systems Inc. - We use information technology to
solve business problems on your plant floor.
http://stratuscom.ca

 -Original Message-
 From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
 Sent: February 24, 2002 20:14
 To: Tomcat Users List
 Subject: RE: Strange javabean problem
 
 
 Thanks for the response. That was exactly the problem.  I should have
 realized that the objects lived in different places (i.e. page context
 VS local variable of the generated servlet).
 
 So is there a better way to do this?  My current plan is to 
 move all of
 this type of table rendering to a taglib so that I don't need the Java
 doing the iteration.
 
 Again thanks for the help.
 
 - Rich
 
 -Original Message-
 From: Greg Trasuk [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, February 22, 2002 11:40 AM
 To: 'Tomcat Users List'
 Subject: RE: Strange javabean problem
 
 
 Hi folks:
 
   Rich, you've put your finger directly on the problem by looking
 at the generated code.  Your scriptlet's way of getting the 
 title is to
 pull it out of the local variable emp, whereas the 
 getProperties version
 is using the JSP's pageContext methods, which end up pulling it out of
 whatever scope it was declared in (your useBean didn't 
 declare a scope,
 so I think it defaults to 'page' scope, but don't quote me on 
 it).  The
 bean in the pageContext is the empty bean that was created by the
 useBean tag, not the populated bean that you're getting from the
 iterator.
 
   Try inserting the following into your loop:
 while(iter.hasNext()) {
  emp = (EmployeeBean)iter.next();
  pageContext.setAttribute(emp,emp); -- Insert this
 line.
   
  %
 
 Cheers,
 
 Greg Trasuk, President
 StratusCom Manufacturing Systems Inc. - We use information 
 technology to
 solve business problems on your plant floor. http://stratuscom.ca
 
  -Original Message-
  From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
  Sent: February 22, 2002 12:15
  To: Tomcat Users List
  Subject: RE: Strange javabean problem
  
  
  Sorry about that.  I should have included how I declared the
  bean.  The
  jsp:useBean tag is the 2nd line in the page, right after the
  jsp:Page tag. The full tag reads:
  
  jsp:useBean id=emp class=test.EmployeeBean /
  
  I've traced through the servlet code and the bean's getters 
 are being 
  called even in the getProperty cases.
  
  In the generated servlet code the scriptlet's version of 
 getting the 
  title is:
  
out.print( emp.getTitle() );
  
  The getProperties version is:
   
  out.print(JspRuntimeLibrary.toStringtest.EmployeeBean)page
  Context.fi
  ndAttribute(emp)).getTitle(;
  
  - Rich
  
  -Original Message-
  From: Randy Layman [mailto:[EMAIL PROTECTED]]
  Sent: Friday, February 22, 2002 7:59 AM
  To: 'Tomcat Users List'
  Subject: RE: Strange javabean problem
  
  
  
  You are not creating a bean named emp for the jsp:getProperty.
 You 
  need to use jsp:useBean first (I believe) or use 
  %=emp.getFirstName()%.
  
  Randy
  
   -Original Message-
   From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
   Sent: Friday, February 22, 2002 11:39 AM
   To: Tomcat Users List
   Subject: RE: Strange javabean problem
   
   
   I can't believe we're the only people who have ever seen
  this problem.
   
   I'm still having the problem but I got to the same place
  differently.
   
   I load the data from a data base in a servlet.  The servlet
  reads from
  
   the database it creates a javabean for each record and 
 adds it to a
   ListArray.  I then add the ArrayList to the request object 
  and forward
  
   on to my JSP.  It's this ArrayList that I'm iterating 
 through in my
   JSP when I have the problem.
   
   Again here is my code snippet that fails:
   
   %
 ArrayList la = (ArrayList) request.getAttribute(list);
 if ( la != null ) {
   Iterator iter = la.iterator();
   while(iter.hasNext()) {
 emp = (EmployeeBean)iter.next();
   %
   trtd%= emp.getFirstName() %/td
   td%= emp.getLastName() %/td
   td%= emp.getTitle() %/td
   /tr
   
   trtdjsp:getProperty name=emp property=firstName //td
   tdjsp:getProperty name=emp property=lastName //td
   tdjsp:getProperty name=emp property=title
  //td /tr %
   }
 }
   %
   
   Could there be something wrong

RE: Strange javabean problem

2002-02-24 Thread Rich Sneiderman

Thanks for the response. That was exactly the problem.  I should have
realized that the objects lived in different places (i.e. page context
VS local variable of the generated servlet).

So is there a better way to do this?  My current plan is to move all of
this type of table rendering to a taglib so that I don't need the Java
doing the iteration.

Again thanks for the help.

- Rich

-Original Message-
From: Greg Trasuk [mailto:[EMAIL PROTECTED]] 
Sent: Friday, February 22, 2002 11:40 AM
To: 'Tomcat Users List'
Subject: RE: Strange javabean problem


Hi folks:

Rich, you've put your finger directly on the problem by looking
at the generated code.  Your scriptlet's way of getting the title is to
pull it out of the local variable emp, whereas the getProperties version
is using the JSP's pageContext methods, which end up pulling it out of
whatever scope it was declared in (your useBean didn't declare a scope,
so I think it defaults to 'page' scope, but don't quote me on it).  The
bean in the pageContext is the empty bean that was created by the
useBean tag, not the populated bean that you're getting from the
iterator.

Try inserting the following into your loop:
while(iter.hasNext()) {
 emp = (EmployeeBean)iter.next();
 pageContext.setAttribute(emp,emp);   -- Insert this
line.
  
 %

Cheers,

Greg Trasuk, President
StratusCom Manufacturing Systems Inc. - We use information technology to
solve business problems on your plant floor. http://stratuscom.ca

 -Original Message-
 From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
 Sent: February 22, 2002 12:15
 To: Tomcat Users List
 Subject: RE: Strange javabean problem
 
 
 Sorry about that.  I should have included how I declared the
 bean.  The
 jsp:useBean tag is the 2nd line in the page, right after the
 jsp:Page tag. The full tag reads:
 
 jsp:useBean id=emp class=test.EmployeeBean /
 
 I've traced through the servlet code and the bean's getters are being 
 called even in the getProperty cases.
 
 In the generated servlet code the scriptlet's version of getting the 
 title is:
 
   out.print( emp.getTitle() );
 
 The getProperties version is:
  
 out.print(JspRuntimeLibrary.toStringtest.EmployeeBean)page
 Context.fi
 ndAttribute(emp)).getTitle(;
 
 - Rich
 
 -Original Message-
 From: Randy Layman [mailto:[EMAIL PROTECTED]]
 Sent: Friday, February 22, 2002 7:59 AM
 To: 'Tomcat Users List'
 Subject: RE: Strange javabean problem
 
 
 
   You are not creating a bean named emp for the jsp:getProperty.
You 
 need to use jsp:useBean first (I believe) or use 
 %=emp.getFirstName()%.
 
   Randy
 
  -Original Message-
  From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
  Sent: Friday, February 22, 2002 11:39 AM
  To: Tomcat Users List
  Subject: RE: Strange javabean problem
  
  
  I can't believe we're the only people who have ever seen
 this problem.
  
  I'm still having the problem but I got to the same place
 differently.
  
  I load the data from a data base in a servlet.  The servlet
 reads from
 
  the database it creates a javabean for each record and adds it to a
  ListArray.  I then add the ArrayList to the request object 
 and forward
 
  on to my JSP.  It's this ArrayList that I'm iterating through in my
  JSP when I have the problem.
  
  Again here is my code snippet that fails:
  
  %
ArrayList la = (ArrayList) request.getAttribute(list);
if ( la != null ) {
  Iterator iter = la.iterator();
  while(iter.hasNext()) {
emp = (EmployeeBean)iter.next();
  %
  trtd%= emp.getFirstName() %/td
  td%= emp.getLastName() %/td
  td%= emp.getTitle() %/td
  /tr
  
  trtdjsp:getProperty name=emp property=firstName //td
  tdjsp:getProperty name=emp property=lastName //td
  tdjsp:getProperty name=emp property=title
 //td /tr %
  }
}
  %
  
  Could there be something wrong with the way we're defining our
  Javabeans?
  
  Please folks.  A little help here.
  
  Thanks in advance.
  
  - Rich
  
  -Original Message-
  From: Michael J. McCormac [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, February 21, 2002 7:45 PM
  To: [EMAIL PROTECTED]
  Cc: Rich Sneiderman
  Subject: RE: Strange javabean problem
  
  
   Hi Folks,
   
   I'm using Tomcat 4.01 with Jbuilder 6.  I've got a
 strange problem.
   It seems that if I try to dump data from a Java bean using the
   jsp:getProperty tag I don't get the data.  However, if I
  reference
   the value of the bean directly in a scriptlet it works fine.
  
  greetings all,
  
  i am having pretty much the same problem, but the
 implementation is a
  little bit different.  i tried using an rmi process to retrieve the
  bean directly from the JSP like so:
  
  jsp:useBean id='myBean' class='beans.MyClass' /
  %
  rmiInt rmiServer = (rmiInt)Naming.lookup( //server/service );
  myBean = (MyClass)rmiServer.getBean();
  %
  jsp:getProperty name='myBean' property

RE: Strange javabean problem

2002-02-22 Thread Michael J. McCormac

 Hi Folks,
 
 I'm using Tomcat 4.01 with Jbuilder 6.  I've got a strange problem.  
 It seems that if I try to dump data from a Java bean using the
 jsp:getProperty tag I don't get the data.  However, if I reference 
 the value of the bean directly in a scriptlet it works fine.

greetings all,

i am having pretty much the same problem, but the implementation is a
little bit different.  i tried using an rmi process to retrieve the bean
directly from the JSP like so:

jsp:useBean id='myBean' class='beans.MyClass' /
%
rmiInt rmiServer = (rmiInt)Naming.lookup( //server/service );
myBean = (MyClass)rmiServer.getBean();
%
jsp:getProperty name='myBean' property='lastName' /  - doesn't work!

one way i've managed to work around the problem was by creating and
loading the beans in a servlet first, throwing the beans in the session
object, then redirecting to the JSP file where i could pull them back
out of the session like this:

jsp:useBean id='myBean' class='beans.MyClass' /
% session.getAttribute( mybean ); %
jsp:getProperty name='myBean' property='lastName' / - works ok!!

but i don't like this solution...  it's inelegant ;)

thanks,
mike


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




RE: Strange javabean problem

2002-02-22 Thread Rich Sneiderman

I can't believe we're the only people who have ever seen this problem.

I'm still having the problem but I got to the same place differently.

I load the data from a data base in a servlet.  The servlet reads from
the database it creates a javabean for each record and adds it to a
ListArray.  I then add the ArrayList to the request object and forward
on to my JSP.  It's this ArrayList that I'm iterating through in my JSP
when I have the problem.

Again here is my code snippet that fails:

%
  ArrayList la = (ArrayList) request.getAttribute(list);
  if ( la != null ) {
Iterator iter = la.iterator();
while(iter.hasNext()) {
  emp = (EmployeeBean)iter.next();
%
trtd%= emp.getFirstName() %/td
td%= emp.getLastName() %/td
td%= emp.getTitle() %/td
/tr

trtdjsp:getProperty name=emp property=firstName //td
tdjsp:getProperty name=emp property=lastName //td
tdjsp:getProperty name=emp property=title //td /tr %
}
  }
%

Could there be something wrong with the way we're defining our
Javabeans?

Please folks.  A little help here.

Thanks in advance.

- Rich

-Original Message-
From: Michael J. McCormac [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, February 21, 2002 7:45 PM
To: [EMAIL PROTECTED]
Cc: Rich Sneiderman
Subject: RE: Strange javabean problem


 Hi Folks,
 
 I'm using Tomcat 4.01 with Jbuilder 6.  I've got a strange problem.
 It seems that if I try to dump data from a Java bean using the
 jsp:getProperty tag I don't get the data.  However, if I reference 
 the value of the bean directly in a scriptlet it works fine.

greetings all,

i am having pretty much the same problem, but the implementation is a
little bit different.  i tried using an rmi process to retrieve the bean
directly from the JSP like so:

jsp:useBean id='myBean' class='beans.MyClass' /
%
rmiInt rmiServer = (rmiInt)Naming.lookup( //server/service );
myBean = (MyClass)rmiServer.getBean();
%
jsp:getProperty name='myBean' property='lastName' /  - doesn't work!

one way i've managed to work around the problem was by creating and
loading the beans in a servlet first, throwing the beans in the session
object, then redirecting to the JSP file where i could pull them back
out of the session like this:

jsp:useBean id='myBean' class='beans.MyClass' /
% session.getAttribute( mybean ); %
jsp:getProperty name='myBean' property='lastName' / - works ok!!

but i don't like this solution...  it's inelegant ;)

thanks,
mike


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




RE: Strange javabean problem

2002-02-22 Thread Randy Layman


You are not creating a bean named emp for the jsp:getProperty.  You
need to use jsp:useBean first (I believe) or use %=emp.getFirstName()%.

Randy

 -Original Message-
 From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
 Sent: Friday, February 22, 2002 11:39 AM
 To: Tomcat Users List
 Subject: RE: Strange javabean problem
 
 
 I can't believe we're the only people who have ever seen this problem.
 
 I'm still having the problem but I got to the same place differently.
 
 I load the data from a data base in a servlet.  The servlet reads from
 the database it creates a javabean for each record and adds it to a
 ListArray.  I then add the ArrayList to the request object and forward
 on to my JSP.  It's this ArrayList that I'm iterating through 
 in my JSP
 when I have the problem.
 
 Again here is my code snippet that fails:
 
 %
   ArrayList la = (ArrayList) request.getAttribute(list);
   if ( la != null ) {
 Iterator iter = la.iterator();
 while(iter.hasNext()) {
   emp = (EmployeeBean)iter.next();
 %
 trtd%= emp.getFirstName() %/td
 td%= emp.getLastName() %/td
 td%= emp.getTitle() %/td
 /tr
 
 trtdjsp:getProperty name=emp property=firstName //td
 tdjsp:getProperty name=emp property=lastName //td
 tdjsp:getProperty name=emp property=title //td /tr %
 }
   }
 %
 
 Could there be something wrong with the way we're defining our
 Javabeans?
 
 Please folks.  A little help here.
 
 Thanks in advance.
 
 - Rich
 
 -Original Message-
 From: Michael J. McCormac [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, February 21, 2002 7:45 PM
 To: [EMAIL PROTECTED]
 Cc: Rich Sneiderman
 Subject: RE: Strange javabean problem
 
 
  Hi Folks,
  
  I'm using Tomcat 4.01 with Jbuilder 6.  I've got a strange problem.
  It seems that if I try to dump data from a Java bean using the
  jsp:getProperty tag I don't get the data.  However, if I 
 reference 
  the value of the bean directly in a scriptlet it works fine.
 
 greetings all,
 
 i am having pretty much the same problem, but the implementation is a
 little bit different.  i tried using an rmi process to 
 retrieve the bean
 directly from the JSP like so:
 
 jsp:useBean id='myBean' class='beans.MyClass' /
 %
   rmiInt rmiServer = (rmiInt)Naming.lookup( //server/service );
   myBean = (MyClass)rmiServer.getBean();
 %
 jsp:getProperty name='myBean' property='lastName' /  - 
 doesn't work!
 
 one way i've managed to work around the problem was by creating and
 loading the beans in a servlet first, throwing the beans in 
 the session
 object, then redirecting to the JSP file where i could pull them back
 out of the session like this:
 
 jsp:useBean id='myBean' class='beans.MyClass' /
 % session.getAttribute( mybean ); %
 jsp:getProperty name='myBean' property='lastName' / - works ok!!
 
 but i don't like this solution...  it's inelegant ;)
 
 thanks,
 mike
 
 
 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]
 
 
 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]
 

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




RE: Strange javabean problem

2002-02-22 Thread Rich Sneiderman

Sorry about that.  I should have included how I declared the bean.  The
jsp:useBean tag is the 2nd line in the page, right after the
jsp:Page tag. The full tag reads:

jsp:useBean id=emp class=test.EmployeeBean /

I've traced through the servlet code and the bean's getters are being
called even in the getProperty cases.  

In the generated servlet code the scriptlet's version of getting the
title is:

  out.print( emp.getTitle() );

The getProperties version is:
 
out.print(JspRuntimeLibrary.toStringtest.EmployeeBean)pageContext.fi
ndAttribute(emp)).getTitle(;

- Rich

-Original Message-
From: Randy Layman [mailto:[EMAIL PROTECTED]] 
Sent: Friday, February 22, 2002 7:59 AM
To: 'Tomcat Users List'
Subject: RE: Strange javabean problem



You are not creating a bean named emp for the jsp:getProperty.
You need to use jsp:useBean first (I believe) or use
%=emp.getFirstName()%.

Randy

 -Original Message-
 From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
 Sent: Friday, February 22, 2002 11:39 AM
 To: Tomcat Users List
 Subject: RE: Strange javabean problem
 
 
 I can't believe we're the only people who have ever seen this problem.
 
 I'm still having the problem but I got to the same place differently.
 
 I load the data from a data base in a servlet.  The servlet reads from

 the database it creates a javabean for each record and adds it to a 
 ListArray.  I then add the ArrayList to the request object and forward

 on to my JSP.  It's this ArrayList that I'm iterating through in my 
 JSP when I have the problem.
 
 Again here is my code snippet that fails:
 
 %
   ArrayList la = (ArrayList) request.getAttribute(list);
   if ( la != null ) {
 Iterator iter = la.iterator();
 while(iter.hasNext()) {
   emp = (EmployeeBean)iter.next();
 %
 trtd%= emp.getFirstName() %/td
 td%= emp.getLastName() %/td
 td%= emp.getTitle() %/td
 /tr
 
 trtdjsp:getProperty name=emp property=firstName //td
 tdjsp:getProperty name=emp property=lastName //td
 tdjsp:getProperty name=emp property=title //td /tr %
 }
   }
 %
 
 Could there be something wrong with the way we're defining our 
 Javabeans?
 
 Please folks.  A little help here.
 
 Thanks in advance.
 
 - Rich
 
 -Original Message-
 From: Michael J. McCormac [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, February 21, 2002 7:45 PM
 To: [EMAIL PROTECTED]
 Cc: Rich Sneiderman
 Subject: RE: Strange javabean problem
 
 
  Hi Folks,
  
  I'm using Tomcat 4.01 with Jbuilder 6.  I've got a strange problem. 
  It seems that if I try to dump data from a Java bean using the 
  jsp:getProperty tag I don't get the data.  However, if I
 reference
  the value of the bean directly in a scriptlet it works fine.
 
 greetings all,
 
 i am having pretty much the same problem, but the implementation is a 
 little bit different.  i tried using an rmi process to retrieve the 
 bean directly from the JSP like so:
 
 jsp:useBean id='myBean' class='beans.MyClass' /
 %
   rmiInt rmiServer = (rmiInt)Naming.lookup( //server/service );
   myBean = (MyClass)rmiServer.getBean();
 %
 jsp:getProperty name='myBean' property='lastName' /  -
 doesn't work!
 
 one way i've managed to work around the problem was by creating and 
 loading the beans in a servlet first, throwing the beans in the 
 session object, then redirecting to the JSP file where i could pull 
 them back out of the session like this:
 
 jsp:useBean id='myBean' class='beans.MyClass' /
 % session.getAttribute( mybean ); %
 jsp:getProperty name='myBean' property='lastName' / - works ok!!
 
 but i don't like this solution...  it's inelegant ;)
 
 thanks,
 mike
 
 
 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]
 
 
 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]
 

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




RE: Strange javabean problem

2002-02-22 Thread Greg Trasuk

Hi folks:

Rich, you've put your finger directly on the problem by looking at
the generated code.  Your scriptlet's way of getting the title is to pull it
out of the local variable emp, whereas the getProperties version is using
the JSP's pageContext methods, which end up pulling it out of whatever scope
it was declared in (your useBean didn't declare a scope, so I think it
defaults to 'page' scope, but don't quote me on it).  The bean in the
pageContext is the empty bean that was created by the useBean tag, not the
populated bean that you're getting from the iterator.

Try inserting the following into your loop:
while(iter.hasNext()) {
 emp = (EmployeeBean)iter.next();
 pageContext.setAttribute(emp,emp);   -- Insert this
line.
  
 %

Cheers,

Greg Trasuk, President
StratusCom Manufacturing Systems Inc. - We use information technology to
solve business problems on your plant floor.
http://stratuscom.ca

 -Original Message-
 From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
 Sent: February 22, 2002 12:15
 To: Tomcat Users List
 Subject: RE: Strange javabean problem
 
 
 Sorry about that.  I should have included how I declared the 
 bean.  The
 jsp:useBean tag is the 2nd line in the page, right after the
 jsp:Page tag. The full tag reads:
 
 jsp:useBean id=emp class=test.EmployeeBean /
 
 I've traced through the servlet code and the bean's getters are being
 called even in the getProperty cases.  
 
 In the generated servlet code the scriptlet's version of getting the
 title is:
 
   out.print( emp.getTitle() );
 
 The getProperties version is:
  
 out.print(JspRuntimeLibrary.toStringtest.EmployeeBean)page
 Context.fi
 ndAttribute(emp)).getTitle(;
 
 - Rich
 
 -Original Message-
 From: Randy Layman [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, February 22, 2002 7:59 AM
 To: 'Tomcat Users List'
 Subject: RE: Strange javabean problem
 
 
 
   You are not creating a bean named emp for the jsp:getProperty.
 You need to use jsp:useBean first (I believe) or use
 %=emp.getFirstName()%.
 
   Randy
 
  -Original Message-
  From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
  Sent: Friday, February 22, 2002 11:39 AM
  To: Tomcat Users List
  Subject: RE: Strange javabean problem
  
  
  I can't believe we're the only people who have ever seen 
 this problem.
  
  I'm still having the problem but I got to the same place 
 differently.
  
  I load the data from a data base in a servlet.  The servlet 
 reads from
 
  the database it creates a javabean for each record and adds it to a 
  ListArray.  I then add the ArrayList to the request object 
 and forward
 
  on to my JSP.  It's this ArrayList that I'm iterating through in my 
  JSP when I have the problem.
  
  Again here is my code snippet that fails:
  
  %
ArrayList la = (ArrayList) request.getAttribute(list);
if ( la != null ) {
  Iterator iter = la.iterator();
  while(iter.hasNext()) {
emp = (EmployeeBean)iter.next();
  %
  trtd%= emp.getFirstName() %/td
  td%= emp.getLastName() %/td
  td%= emp.getTitle() %/td
  /tr
  
  trtdjsp:getProperty name=emp property=firstName //td
  tdjsp:getProperty name=emp property=lastName //td
  tdjsp:getProperty name=emp property=title 
 //td /tr %
  }
}
  %
  
  Could there be something wrong with the way we're defining our 
  Javabeans?
  
  Please folks.  A little help here.
  
  Thanks in advance.
  
  - Rich
  
  -Original Message-
  From: Michael J. McCormac [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, February 21, 2002 7:45 PM
  To: [EMAIL PROTECTED]
  Cc: Rich Sneiderman
  Subject: RE: Strange javabean problem
  
  
   Hi Folks,
   
   I'm using Tomcat 4.01 with Jbuilder 6.  I've got a 
 strange problem. 
   It seems that if I try to dump data from a Java bean using the 
   jsp:getProperty tag I don't get the data.  However, if I
  reference
   the value of the bean directly in a scriptlet it works fine.
  
  greetings all,
  
  i am having pretty much the same problem, but the 
 implementation is a 
  little bit different.  i tried using an rmi process to retrieve the 
  bean directly from the JSP like so:
  
  jsp:useBean id='myBean' class='beans.MyClass' /
  %
  rmiInt rmiServer = (rmiInt)Naming.lookup( //server/service );
  myBean = (MyClass)rmiServer.getBean();
  %
  jsp:getProperty name='myBean' property='lastName' /  -
  doesn't work!
  
  one way i've managed to work around the problem was by creating and 
  loading the beans in a servlet first, throwing the beans in the 
  session object, then redirecting to the JSP file where i could pull 
  them back out of the session like this:
  
  jsp:useBean id='myBean' class='beans.MyClass' /
  % session.getAttribute( mybean ); %
  jsp:getProperty name='myBean' property='lastName' / - works ok!!
  
  but i don't like this solution...  it's inelegant ;)
  
  thanks,
  mike
  
  
  --
  To unsubscribe

RE: Strange javabean problem

2002-02-18 Thread Jarecsni Janos

Hi,

I'm not sure at all if this is the problem but let's see:
do you use jsp:useBean tag for the emp page bean? AFAIK that tag is
responsible for creating the object in page's context.

hope this helps

Janos

|-Original Message-
|From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
|Sent: Tuesday, February 19, 2002 6:51 AM
|To: [EMAIL PROTECTED]
|Subject: Strange javabean problem
|
|
|Hi Folks,
|
|I'm using Tomcat 4.01 with Jbuilder 6.  I've got a strange problem.  It
|seems that if I try to dump data from a Java bean using the
|jsp:getProperty tag I don't get the data.  However, if I reference the
|value of the bean directly in a scriptlet it works fine.
|
|Here's a code snippet:
|
|%
|  ArrayList la = (ArrayList) request.getAttribute(list);
|  if ( la != null ) {
|Iterator iter = la.iterator();
|while(iter.hasNext()) {
|  emp = (EmployeeBean)iter.next();
|%
|trtd%= emp.getFirstName() %/td
|td%= emp.getLastName() %/td
|td%= emp.getTitle() %/td
|/tr
|
|trtdjsp:getProperty name=emp property=firstName //td
|tdjsp:getProperty name=emp property=lastName //td
|tdjsp:getProperty name=emp property=title //td
|/tr
|%
|}
|  }
|%
|
|The getters work but the jsp:getProperty that immediately follows
|doesn't.  The strings are not in the generated HTML.  I've looked at the
|generated servlet code and it looks ok.
|
|The scriptlet's version of one line is:
|  out.print( emp.getTitle() );
|
|The getProperties version is:
|
|out.print(JspRuntimeLibrary.toStringtest.EmployeeBean)pageContext.fi
|ndAttribute(emp)).getTitle(;
|
|One more thing.  I walked through the code with the debugger and the
|getter is being called in both instances.
|
|Any suggestion on where I should look?  Any help would be appreciated.
|
|- Rich
|
|--
|To unsubscribe:   mailto:[EMAIL PROTECTED]
|For additional commands: mailto:[EMAIL PROTECTED]
|Troubles with the list: mailto:[EMAIL PROTECTED]
|
|


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




RE: Strange javabean problem

2002-02-18 Thread Rich Sneiderman

If you mean do I define the bean before I use it.  Yup.  Second line in
the jsp is:

jsp:useBean id=emp class=test.EmployeeBean /

- Rich

-Original Message-
From: Jarecsni Janos [mailto:[EMAIL PROTECTED]] 
Sent: Monday, February 18, 2002 10:03 PM
To: Tomcat Users List
Subject: RE: Strange javabean problem


Hi,

I'm not sure at all if this is the problem but let's see:
do you use jsp:useBean tag for the emp page bean? AFAIK that tag is
responsible for creating the object in page's context.

hope this helps

Janos

|-Original Message-
|From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
|Sent: Tuesday, February 19, 2002 6:51 AM
|To: [EMAIL PROTECTED]
|Subject: Strange javabean problem
|
|
|Hi Folks,
|
|I'm using Tomcat 4.01 with Jbuilder 6.  I've got a strange problem.  It

|seems that if I try to dump data from a Java bean using the 
|jsp:getProperty tag I don't get the data.  However, if I reference 
|the value of the bean directly in a scriptlet it works fine.
|
|Here's a code snippet:
|
|%
|  ArrayList la = (ArrayList) request.getAttribute(list);
|  if ( la != null ) {
|Iterator iter = la.iterator();
|while(iter.hasNext()) {
|  emp = (EmployeeBean)iter.next();
|%
|trtd%= emp.getFirstName() %/td
|td%= emp.getLastName() %/td
|td%= emp.getTitle() %/td
|/tr
|
|trtdjsp:getProperty name=emp property=firstName //td
|tdjsp:getProperty name=emp property=lastName //td
|tdjsp:getProperty name=emp property=title //td /tr
|%
|}
|  }
|%
|
|The getters work but the jsp:getProperty that immediately follows 
|doesn't.  The strings are not in the generated HTML.  I've looked at 
|the generated servlet code and it looks ok.
|
|The scriptlet's version of one line is:
|  out.print( emp.getTitle() );
|
|The getProperties version is:
|
|out.print(JspRuntimeLibrary.toStringtest.EmployeeBean)pageContext.f
|i
|ndAttribute(emp)).getTitle(;
|
|One more thing.  I walked through the code with the debugger and the 
|getter is being called in both instances.
|
|Any suggestion on where I should look?  Any help would be appreciated.
|
|- Rich
|
|--
|To unsubscribe:   mailto:[EMAIL PROTECTED]
|For additional commands: mailto:[EMAIL PROTECTED]
|Troubles with the list: mailto:[EMAIL PROTECTED]
|
|


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]