RE: how do I reference a bean that's inside my jsp page?

2003-01-14 Thread Noel J. Bergman
 I cannot imagine how that would work in any app
 server. A Java bean is it's own class that can
 be used by ...

It works just fine in other JSP engines, e.g., GNUJSP.  The example was just
a self-contained example for introducing bean tags, and the specific use is
limited to form handling where the bean is intended to have a 1:1
relationship with the HTML form.  The documentation mentions that it is a
limited application (you *must* use page scope because the bean cannot be
used outside of that page, and any other scope would lead to classloader
problems).

--- Noel


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: how do I reference a bean that's inside my jsp page?

2003-01-14 Thread Noel J. Bergman
Jeff,

Thanks for reminding me.  This is not the cleanest thing to do from a
purist's perspective (which I mention in the tutorial), but it was a simple
demonstration, and it works for form generation tools.

More importantly, there is nothing in the JSP Specification that prohibits
this behavior.  Tomcat's current lack of support for it therefore appears to
be a defect.  Either they should fix it, or Sun should amend the
specification.  Tomcat is the Reference Implementation, so one or the other
needs to be fixed.

I keep forgetting to stick this in bugzilla.

--- Noel


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: how do I reference a bean that's inside my jsp page?

2003-01-13 Thread Charles Baker

--- Jeff Ousley [EMAIL PROTECTED] wrote:
 Hello,
 
 I cannot seem to get this example below to work
 under
 tomcat (I'm using version 4.1.18). I get an error
 indicating that the class localBean cannot be found
 such as:
 
 
 java.lang.ClassNotFoundException: localBean
   at

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1428)
   at

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1274)
 
 
 
 
 I tried doing an import (which is now commented out)
 to no avail. Can I not have a bean in my jsp page?
 If
 I can, how do I reference it or what do I set so
 that
 it can be found?
 
 thanks!
 
 
 
 example page
 
 
 HTML
 %-- %@ page import=localBean % --%
 
 %!
 // this is a local helper bean for processing the
 HTML form
 static public class localBean
 {
private String value;
public String getValue() { return value;}
public void setValue(String s)   { value = s; }
 }
 %
 
 jsp:useBean id=localBean scope=page
 class=localBean 

Where is the bean class file? Is it in 

$CATALINA_HOME/webapps/yourApp/WEB-INF/classes ?

Is the bean in a package? If so, it needs to be in a
corresponding directory structure under classes. Is
you bean in fact named localBean.[java|class] ?
Convention says Java classes should be named
LocalBean.java.

{{SNIP}}

=
[EMAIL PROTECTED]
http://www.charleshbaker.com/~chb/
If you cannot in the long run tell everyone what you have been doing,
your doing was worthless. -- Edwim Schrodinger

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: how do I reference a bean that's inside my jsp page?

2003-01-13 Thread Denise Mangano
Jeff,

I'm not exactly sure what you mean by a bean that is inside your JSP (then
again I'm a newbie...), but I am assuming you mean have access to a bean
from within your JSP.

The way I use my bean, is I created the file MyBean.java with all the proper
methods and compiled it.  These files (the .java and .class) are in the
WEB-INF/classes/com/complusdata/beans directory of my webapp.  Now I've
noticed that I have had to restart Tomcat every time I make changes to the
bean and recompile, but someone on the list may have a better solution to
that...

In MyBean.java I declare 

package com.complusdata.beans;  

To reference the bean from myJSP.jsp that is in my webapp directory, I have
the following:

%@page import=com.complusdata.beans%

jsp:useBean id=myBean class=com.complusdata.beans.MyBean
scope=request
  jsp:setProperty name=myBean property=*/
/jsp:useBean

As I've learned from the list, this will tell the JSP to use the bean
myBean.  It will first look for an existing instance of the bean.  If one
does not exist it will execute the body of the jsp:useBean tag.  If an
instance does exist it will not execute the body.  Then in either case, you
will have access to the properties of that bean.  

When I want to access a specific value from the bean within my JSP page, I
use myBean.getPropertyName() - where you substitute PropertyName for the
name of your property.  I believe you can also use the tag jsp:getProperty
name=myBean property=propertyName/

I also have my webapps directory in my Classpath, but not sure if that is
required...

On a side note, anyone feel free to correct me if I am wrong about something
;) but Jeff, this is how mine is set up.

HTH
Denise

-Original Message-
From: Jeff Ousley [mailto:[EMAIL PROTECTED]] 
Sent: Monday, January 13, 2003 5:38 PM
To: [EMAIL PROTECTED]
Subject: how do I reference a bean that's inside my jsp page?


Hello,

I cannot seem to get this example below to work under
tomcat (I'm using version 4.1.18). I get an error
indicating that the class localBean cannot be found
such as:


java.lang.ClassNotFoundException: localBean
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1428)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1274)




I tried doing an import (which is now commented out)
to no avail. Can I not have a bean in my jsp page? If
I can, how do I reference it or what do I set so that
it can be found?

thanks!



example page


HTML
%-- %@ page import=localBean % --%

%!
// this is a local helper bean for processing the
HTML form
static public class localBean
{
   private String value;
   public String getValue() { return value;}
   public void setValue(String s)   { value = s; }
}
%

jsp:useBean id=localBean scope=page
class=localBean 
%-- Every time we create the bean, initialize the
string  --%
jsp:setProperty name=localBean property=value value=World /
/jsp:useBean

%-- Whatever HTTP parameters we have,
 try to set an analogous bean property  --% jsp:setProperty
name=localBean property=* /

HEADTITLEHelloWorld w/ JavaBean/TITLE/HEAD
BODY
CENTER
PH1Hello
jsp:getProperty name='localBean'
property='value'//H1/P
FORM method=post
Enter a name to be greeted:
INPUT TYPE=text SIZE=32 NAME=value VALUE=jsp:getProperty
name='localBean' property='value'/ BR INPUT TYPE=submit
VALUE=Submit /FORM /CENTER /BODY /HTML

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: how do I reference a bean that's inside my jsp page?

2003-01-13 Thread Denise Mangano
Jeff,

My apologies... I just re-read your post, and it looks like you actually
want to define your bean within your JSP page... I do not think this is
possible.  I would imagine not because from what I understand the bean is an
actual class file, which would not be created in your scenario.  Then again,
I could be wrong... However, the scenario I gave works.

HTH
Denise

-Original Message-
From: Denise Mangano [mailto:[EMAIL PROTECTED]] 
Sent: Monday, January 13, 2003 6:54 PM
To: 'Tomcat Users List'
Subject: RE: how do I reference a bean that's inside my jsp page?


Jeff,

I'm not exactly sure what you mean by a bean that is inside your JSP (then
again I'm a newbie...), but I am assuming you mean have access to a bean
from within your JSP.

The way I use my bean, is I created the file MyBean.java with all the proper
methods and compiled it.  These files (the .java and .class) are in the
WEB-INF/classes/com/complusdata/beans directory of my webapp.  Now I've
noticed that I have had to restart Tomcat every time I make changes to the
bean and recompile, but someone on the list may have a better solution to
that...

In MyBean.java I declare 

package com.complusdata.beans;  

To reference the bean from myJSP.jsp that is in my webapp directory, I have
the following:

%@page import=com.complusdata.beans%

jsp:useBean id=myBean class=com.complusdata.beans.MyBean
scope=request
  jsp:setProperty name=myBean property=*/
/jsp:useBean

As I've learned from the list, this will tell the JSP to use the bean
myBean.  It will first look for an existing instance of the bean.  If one
does not exist it will execute the body of the jsp:useBean tag.  If an
instance does exist it will not execute the body.  Then in either case, you
will have access to the properties of that bean.  

When I want to access a specific value from the bean within my JSP page, I
use myBean.getPropertyName() - where you substitute PropertyName for the
name of your property.  I believe you can also use the tag jsp:getProperty
name=myBean property=propertyName/

I also have my webapps directory in my Classpath, but not sure if that is
required...

On a side note, anyone feel free to correct me if I am wrong about something
;) but Jeff, this is how mine is set up.

HTH
Denise

-Original Message-
From: Jeff Ousley [mailto:[EMAIL PROTECTED]] 
Sent: Monday, January 13, 2003 5:38 PM
To: [EMAIL PROTECTED]
Subject: how do I reference a bean that's inside my jsp page?


Hello,

I cannot seem to get this example below to work under
tomcat (I'm using version 4.1.18). I get an error
indicating that the class localBean cannot be found
such as:


java.lang.ClassNotFoundException: localBean
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1428)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1274)




I tried doing an import (which is now commented out)
to no avail. Can I not have a bean in my jsp page? If
I can, how do I reference it or what do I set so that
it can be found?

thanks!



example page


HTML
%-- %@ page import=localBean % --%

%!
// this is a local helper bean for processing the
HTML form
static public class localBean
{
   private String value;
   public String getValue() { return value;}
   public void setValue(String s)   { value = s; }
}
%

jsp:useBean id=localBean scope=page
class=localBean 
%-- Every time we create the bean, initialize the
string  --%
jsp:setProperty name=localBean property=value value=World /
/jsp:useBean

%-- Whatever HTTP parameters we have,
 try to set an analogous bean property  --% jsp:setProperty
name=localBean property=* /

HEADTITLEHelloWorld w/ JavaBean/TITLE/HEAD
BODY
CENTER
PH1Hello
jsp:getProperty name='localBean'
property='value'//H1/P
FORM method=post
Enter a name to be greeted:
INPUT TYPE=text SIZE=32 NAME=value VALUE=jsp:getProperty
name='localBean' property='value'/ BR INPUT TYPE=submit
VALUE=Submit /FORM /CENTER /BODY /HTML

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail: mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: how do I reference a bean that's inside my jsp page?

2003-01-13 Thread Jeff Ousley
Charles,

The bean is actually on the same page in a declaration
block. If I pull the bean out and put it into it's own
class file, I can get it to work. I was just trying to
get the example from the tutorial to work. It seems to
work on the tutorial site, but I'm not sure what
application server they are using.

-jeff

--- Charles Baker [EMAIL PROTECTED] wrote:
 
 --- Jeff Ousley [EMAIL PROTECTED] wrote:
  Hello,
  
  I cannot seem to get this example below to work
  under
  tomcat (I'm using version 4.1.18). I get an error
  indicating that the class localBean cannot be
 found
  such as:
  
  
  java.lang.ClassNotFoundException: localBean
  at
 

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1428)
  at
 

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1274)
  
  
  
  
  I tried doing an import (which is now commented
 out)
  to no avail. Can I not have a bean in my jsp page?
  If
  I can, how do I reference it or what do I set so
  that
  it can be found?
  
  thanks!
  
  
  
  example page
  
  
  HTML
  %-- %@ page import=localBean % --%
  
  %!
  // this is a local helper bean for processing
 the
  HTML form
  static public class localBean
  {
 private String value;
 public String getValue() { return
 value;}
 public void setValue(String s)   { value = s; }
  }
  %
  
  jsp:useBean id=localBean scope=page
  class=localBean 
 
 Where is the bean class file? Is it in 
 
 $CATALINA_HOME/webapps/yourApp/WEB-INF/classes ?
 
 Is the bean in a package? If so, it needs to be in a
 corresponding directory structure under classes. Is
 you bean in fact named localBean.[java|class] ?
 Convention says Java classes should be named
 LocalBean.java.
 
 {{SNIP}}
 
 =
 [EMAIL PROTECTED]
 http://www.charleshbaker.com/~chb/
 If you cannot in the long run tell everyone what you
 have been doing,
 your doing was worthless. -- Edwim Schrodinger
 
 __
 Do you Yahoo!?
 Yahoo! Mail Plus - Powerful. Affordable. Sign up
 now.
 http://mailplus.yahoo.com
 
 --
 To unsubscribe, e-mail:  
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]
 


__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: how do I reference a bean that's inside my jsp page?

2003-01-13 Thread Jeff Ousley
Denise,

Thanks for the response. I got it to work by pulling
the bean out into it's own class file. I'm just trying
to understand this example from a tutorial I'm going
through. It works on their site. However, I'm not sure
which app server they are using.

-jeff
--- Denise Mangano [EMAIL PROTECTED] wrote:
 Jeff,
 
 My apologies... I just re-read your post, and it
 looks like you actually
 want to define your bean within your JSP page... I
 do not think this is
 possible.  I would imagine not because from what I
 understand the bean is an
 actual class file, which would not be created in
 your scenario.  Then again,
 I could be wrong... However, the scenario I gave
 works.
 
 HTH
 Denise
 
 -Original Message-
 From: Denise Mangano
 [mailto:[EMAIL PROTECTED]] 
 Sent: Monday, January 13, 2003 6:54 PM
 To: 'Tomcat Users List'
 Subject: RE: how do I reference a bean that's inside
 my jsp page?
 
 
 Jeff,
 
 I'm not exactly sure what you mean by a bean that is
 inside your JSP (then
 again I'm a newbie...), but I am assuming you mean
 have access to a bean
 from within your JSP.
 
 The way I use my bean, is I created the file
 MyBean.java with all the proper
 methods and compiled it.  These files (the .java and
 .class) are in the
 WEB-INF/classes/com/complusdata/beans directory of
 my webapp.  Now I've
 noticed that I have had to restart Tomcat every time
 I make changes to the
 bean and recompile, but someone on the list may have
 a better solution to
 that...
 
 In MyBean.java I declare 
 
 package com.complusdata.beans;  
 
 To reference the bean from myJSP.jsp that is in my
 webapp directory, I have
 the following:
 
 %@page import=com.complusdata.beans%
 
 jsp:useBean id=myBean
 class=com.complusdata.beans.MyBean
 scope=request
   jsp:setProperty name=myBean property=*/
 /jsp:useBean
 
 As I've learned from the list, this will tell the
 JSP to use the bean
 myBean.  It will first look for an existing
 instance of the bean.  If one
 does not exist it will execute the body of the
 jsp:useBean tag.  If an
 instance does exist it will not execute the body. 
 Then in either case, you
 will have access to the properties of that bean.  
 
 When I want to access a specific value from the bean
 within my JSP page, I
 use myBean.getPropertyName() - where you substitute
 PropertyName for the
 name of your property.  I believe you can also use
 the tag jsp:getProperty
 name=myBean property=propertyName/
 
 I also have my webapps directory in my Classpath,
 but not sure if that is
 required...
 
 On a side note, anyone feel free to correct me if I
 am wrong about something
 ;) but Jeff, this is how mine is set up.
 
 HTH
 Denise
 
 -Original Message-
 From: Jeff Ousley [mailto:[EMAIL PROTECTED]] 
 Sent: Monday, January 13, 2003 5:38 PM
 To: [EMAIL PROTECTED]
 Subject: how do I reference a bean that's inside my
 jsp page?
 
 
 Hello,
 
 I cannot seem to get this example below to work
 under
 tomcat (I'm using version 4.1.18). I get an error
 indicating that the class localBean cannot be found
 such as:
 
 
 java.lang.ClassNotFoundException: localBean
   at

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
 a:1428)
   at

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
 a:1274)
 
 
 
 
 I tried doing an import (which is now commented out)
 to no avail. Can I not have a bean in my jsp page?
 If
 I can, how do I reference it or what do I set so
 that
 it can be found?
 
 thanks!
 
 
 
 example page
 
 
 HTML
 %-- %@ page import=localBean % --%
 
 %!
 // this is a local helper bean for processing the
 HTML form
 static public class localBean
 {
private String value;
public String getValue() { return value;}
public void setValue(String s)   { value = s; }
 }
 %
 
 jsp:useBean id=localBean scope=page
 class=localBean 
 %-- Every time we create the bean, initialize the
 string  --%
 jsp:setProperty name=localBean property=value
 value=World /
 /jsp:useBean
 
 %-- Whatever HTTP parameters we have,
  try to set an analogous bean property  --%
 jsp:setProperty
 name=localBean property=* /
 
 HEADTITLEHelloWorld w/ JavaBean/TITLE/HEAD
 BODY
 CENTER
 PH1Hello
 jsp:getProperty name='localBean'
 property='value'//H1/P
 FORM method=post
 Enter a name to be greeted:
 INPUT TYPE=text SIZE=32 NAME=value
 VALUE=jsp:getProperty
 name='localBean' property='value'/ BR INPUT
 TYPE=submit
 VALUE=Submit /FORM /CENTER /BODY /HTML
 
 __
 Do you Yahoo!?
 Yahoo! Mail Plus - Powerful. Affordable. Sign up
 now.
 http://mailplus.yahoo.com
 
 --
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]
 
 --
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]
 
 --
 To unsubscribe, e-mail:  
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL

RE: how do I reference a bean that's inside my jsp page?

2003-01-13 Thread Denise Mangano
Jeff,

Is there a website for that tutorial?  I'd be curious myself to see if such
a scenario is possible...

Thanks :)
Denise

-Original Message-
From: Jeff Ousley [mailto:[EMAIL PROTECTED]] 
Sent: Monday, January 13, 2003 7:07 PM
To: Tomcat Users List
Subject: RE: how do I reference a bean that's inside my jsp page?


Denise,

Thanks for the response. I got it to work by pulling
the bean out into it's own class file. I'm just trying
to understand this example from a tutorial I'm going
through. It works on their site. However, I'm not sure
which app server they are using.

-jeff
--- Denise Mangano [EMAIL PROTECTED] wrote:
 Jeff,
 
 My apologies... I just re-read your post, and it
 looks like you actually
 want to define your bean within your JSP page... I
 do not think this is
 possible.  I would imagine not because from what I
 understand the bean is an
 actual class file, which would not be created in
 your scenario.  Then again,
 I could be wrong... However, the scenario I gave
 works.
 
 HTH
 Denise
 
 -Original Message-
 From: Denise Mangano
 [mailto:[EMAIL PROTECTED]]
 Sent: Monday, January 13, 2003 6:54 PM
 To: 'Tomcat Users List'
 Subject: RE: how do I reference a bean that's inside
 my jsp page?
 
 
 Jeff,
 
 I'm not exactly sure what you mean by a bean that is
 inside your JSP (then
 again I'm a newbie...), but I am assuming you mean
 have access to a bean
 from within your JSP.
 
 The way I use my bean, is I created the file
 MyBean.java with all the proper
 methods and compiled it.  These files (the .java and
 .class) are in the
 WEB-INF/classes/com/complusdata/beans directory of
 my webapp.  Now I've
 noticed that I have had to restart Tomcat every time
 I make changes to the
 bean and recompile, but someone on the list may have
 a better solution to
 that...
 
 In MyBean.java I declare
 
 package com.complusdata.beans;
 
 To reference the bean from myJSP.jsp that is in my
 webapp directory, I have
 the following:
 
 %@page import=com.complusdata.beans%
 
 jsp:useBean id=myBean
 class=com.complusdata.beans.MyBean
 scope=request
   jsp:setProperty name=myBean property=*/ /jsp:useBean
 
 As I've learned from the list, this will tell the
 JSP to use the bean
 myBean.  It will first look for an existing
 instance of the bean.  If one
 does not exist it will execute the body of the
 jsp:useBean tag.  If an
 instance does exist it will not execute the body.
 Then in either case, you
 will have access to the properties of that bean.  
 
 When I want to access a specific value from the bean
 within my JSP page, I
 use myBean.getPropertyName() - where you substitute PropertyName for 
 the name of your property.  I believe you can also use
 the tag jsp:getProperty
 name=myBean property=propertyName/
 
 I also have my webapps directory in my Classpath,
 but not sure if that is
 required...
 
 On a side note, anyone feel free to correct me if I
 am wrong about something
 ;) but Jeff, this is how mine is set up.
 
 HTH
 Denise
 
 -Original Message-
 From: Jeff Ousley [mailto:[EMAIL PROTECTED]]
 Sent: Monday, January 13, 2003 5:38 PM
 To: [EMAIL PROTECTED]
 Subject: how do I reference a bean that's inside my
 jsp page?
 
 
 Hello,
 
 I cannot seem to get this example below to work
 under
 tomcat (I'm using version 4.1.18). I get an error
 indicating that the class localBean cannot be found
 such as:
 
 
 java.lang.ClassNotFoundException: localBean
   at

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
 a:1428)
   at

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
 a:1274)
 
 
 
 
 I tried doing an import (which is now commented out)
 to no avail. Can I not have a bean in my jsp page?
 If
 I can, how do I reference it or what do I set so
 that
 it can be found?
 
 thanks!
 
 
 
 example page
 
 
 HTML
 %-- %@ page import=localBean % --%
 
 %!
 // this is a local helper bean for processing the
 HTML form
 static public class localBean
 {
private String value;
public String getValue() { return value;}
public void setValue(String s)   { value = s; }
 }
 %
 
 jsp:useBean id=localBean scope=page
 class=localBean 
 %-- Every time we create the bean, initialize the
 string  --%
 jsp:setProperty name=localBean property=value value=World /
 /jsp:useBean
 
 %-- Whatever HTTP parameters we have,
  try to set an analogous bean property  --% jsp:setProperty
 name=localBean property=* /
 
 HEADTITLEHelloWorld w/ JavaBean/TITLE/HEAD
 BODY
 CENTER
 PH1Hello
 jsp:getProperty name='localBean'
 property='value'//H1/P
 FORM method=post
 Enter a name to be greeted:
 INPUT TYPE=text SIZE=32 NAME=value VALUE=jsp:getProperty
 name='localBean' property='value'/ BR INPUT
 TYPE=submit
 VALUE=Submit /FORM /CENTER /BODY /HTML
 
 __
 Do you Yahoo!?
 Yahoo! Mail Plus - Powerful. Affordable. Sign up
 now.
 http://mailplus.yahoo.com
 
 --
 To unsubscribe, e-mail

Re: how do I reference a bean that's inside my jsp page?

2003-01-13 Thread Charles Baker

--- Jeff Ousley [EMAIL PROTECTED] wrote:
 Charles,
 
 The bean is actually on the same page in a
 declaration
 block. If I pull the bean out and put it into it's
 own
 class file, I can get it to work. I was just trying
 to
 get the example from the tutorial to work. It seems
 to
 work on the tutorial site, but I'm not sure what
 application server they are using.
 
 -jeff

{{SNIP}}

I cannot imagine how that would work in any app
server. A Java bean is it's own class that can be used
by a jsp, a servlet, or even a Java gui app. Strange.
What tutorial are you looking at?

=
[EMAIL PROTECTED]
http://www.charleshbaker.com/~chb/
If you cannot in the long run tell everyone what you have been doing,
your doing was worthless. -- Edwim Schrodinger

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: how do I reference a bean that's inside my jsp page?

2003-01-13 Thread Jeff Ousley
Denise  Charles,

I found the tutorial at:

http://www.ibm.com/developerworks

When you get there, on the left, click on Java
Technology, then click on Education. In the list
that comes up, you'll see a tutorial titled:

Introduction to JavaServer Pages technology

That's the one I was going through. There are a lot of
other neat tutorials there as well. Enjoy!

-jeff

--- Denise Mangano [EMAIL PROTECTED] wrote:
 Jeff,
 
 Is there a website for that tutorial?  I'd be
 curious myself to see if such
 a scenario is possible...
 
 Thanks :)
 Denise
 
 -Original Message-
 From: Jeff Ousley [mailto:[EMAIL PROTECTED]] 
 Sent: Monday, January 13, 2003 7:07 PM
 To: Tomcat Users List
 Subject: RE: how do I reference a bean that's inside
 my jsp page?
 
 
 Denise,
 
 Thanks for the response. I got it to work by pulling
 the bean out into it's own class file. I'm just
 trying
 to understand this example from a tutorial I'm going
 through. It works on their site. However, I'm not
 sure
 which app server they are using.
 
 -jeff
 --- Denise Mangano [EMAIL PROTECTED] wrote:
  Jeff,
  
  My apologies... I just re-read your post, and it
  looks like you actually
  want to define your bean within your JSP page... I
  do not think this is
  possible.  I would imagine not because from what I
  understand the bean is an
  actual class file, which would not be created in
  your scenario.  Then again,
  I could be wrong... However, the scenario I gave
  works.
  
  HTH
  Denise
  
  -Original Message-
  From: Denise Mangano
  [mailto:[EMAIL PROTECTED]]
  Sent: Monday, January 13, 2003 6:54 PM
  To: 'Tomcat Users List'
  Subject: RE: how do I reference a bean that's
 inside
  my jsp page?
  
  
  Jeff,
  
  I'm not exactly sure what you mean by a bean that
 is
  inside your JSP (then
  again I'm a newbie...), but I am assuming you mean
  have access to a bean
  from within your JSP.
  
  The way I use my bean, is I created the file
  MyBean.java with all the proper
  methods and compiled it.  These files (the .java
 and
  .class) are in the
  WEB-INF/classes/com/complusdata/beans directory of
  my webapp.  Now I've
  noticed that I have had to restart Tomcat every
 time
  I make changes to the
  bean and recompile, but someone on the list may
 have
  a better solution to
  that...
  
  In MyBean.java I declare
  
  package com.complusdata.beans;
  
  To reference the bean from myJSP.jsp that is in my
  webapp directory, I have
  the following:
  
  %@page import=com.complusdata.beans%
  
  jsp:useBean id=myBean
  class=com.complusdata.beans.MyBean
  scope=request
jsp:setProperty name=myBean property=*/
 /jsp:useBean
  
  As I've learned from the list, this will tell the
  JSP to use the bean
  myBean.  It will first look for an existing
  instance of the bean.  If one
  does not exist it will execute the body of the
  jsp:useBean tag.  If an
  instance does exist it will not execute the body.
  Then in either case, you
  will have access to the properties of that bean.  
  
  When I want to access a specific value from the
 bean
  within my JSP page, I
  use myBean.getPropertyName() - where you
 substitute PropertyName for 
  the name of your property.  I believe you can also
 use
  the tag jsp:getProperty
  name=myBean property=propertyName/
  
  I also have my webapps directory in my Classpath,
  but not sure if that is
  required...
  
  On a side note, anyone feel free to correct me if
 I
  am wrong about something
  ;) but Jeff, this is how mine is set up.
  
  HTH
  Denise
  
  -Original Message-
  From: Jeff Ousley [mailto:[EMAIL PROTECTED]]
  Sent: Monday, January 13, 2003 5:38 PM
  To: [EMAIL PROTECTED]
  Subject: how do I reference a bean that's inside
 my
  jsp page?
  
  
  Hello,
  
  I cannot seem to get this example below to work
  under
  tomcat (I'm using version 4.1.18). I get an error
  indicating that the class localBean cannot be
 found
  such as:
  
  
  java.lang.ClassNotFoundException: localBean
  at
 

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
  a:1428)
  at
 

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
  a:1274)
  
  
  
  
  I tried doing an import (which is now commented
 out)
  to no avail. Can I not have a bean in my jsp page?
  If
  I can, how do I reference it or what do I set so
  that
  it can be found?
  
  thanks!
  
  
  
  example page
  
  
  HTML
  %-- %@ page import=localBean % --%
  
  %!
  // this is a local helper bean for processing
 the
  HTML form
  static public class localBean
  {
 private String value;
 public String getValue() { return
 value;}
 public void setValue(String s)   { value = s; }
  }
  %
  
  jsp:useBean id=localBean scope=page
  class=localBean 
  %-- Every time we create the bean, initialize the
  string  --%
  jsp:setProperty name=localBean property=value
 value=World /
  /jsp:useBean
  
  %-- Whatever HTTP parameters we