RE: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Bhat, Mahesh
Title: Re: problems installing tomcat on linux



Hi

Have you tried 
the simple way of :

com.blah.blah.MyBean abean = new 
com.blah.blah.MyBean();request.setAttribute("thename", abean);

in JSP : 
com.blah.blah.MyBean abean = 
request.getAttribute("thename");

regards
mahesh



  -Original Message-From: Leon Palermo 
  [mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:02 
  PMTo: [EMAIL PROTECTED]Subject: (EXPERTS 
  ONLY) Bean Creation in Dispatch Servlet
  Hello All,
  
  Let me preface this email by saying that I only 
  put 'EXPERTS ONLY' so you hot shot programmers would actually read this 
  email. If you are reading this, it worked!
  
  I have an odd problem that I was hoping someone 
  could help with.
  
  I have a servlet that all jsps in the system are 
  dispatched from. I create a bean in this servlet and add it to the 
  request object like so...
  
   com.blah.blah.MyBean abean = 
  (com.blah.blah.MyBean) 
  Beans.instantiate(this.getClass().getClassLoader(),"com.blah.blah.MyBean"); 
  ...
   
  request.setAttribute("thename", 
  abean); 
  
  I have also tried this to create the 
  bean
  
   com.blah.blah.MyBean abean = 
  new com.blah.blah.MyBean();
  
  and also tried to place the object in the request like 
so
  
   
  pageContext.setAttribute("thename", abean, 
  PageContext.REQUEST_SCOPE);
  
  Anywho, I then have the following in my jsp 
  page...
  
   jsp:useBean id="thename" 
  scope="request" class="com.blah.blah.MyBean" /
  
  I get a java.lang.ClassCastException from the 
  jsp. So, I decided to do a little error hunting ina jsp using the 
  following code...
  
  %try{ 
  System.out.println(request.getAttribute("thename") == null);
   
  System.out.println(request.getAttribute("thename") instanceof 
  com.blah.blah.MyBean); 
  System.out.println(request.getAttribute("thename").getClass().getName()); 
  System.out.println(zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thename"));
  }catch (ClassCastException 
  e){ System.out.println("CLASS CAST 
  EXCEPTION!");}%
  
  The results of the code is as 
  follows:
  
   false
   false
   
  com.blah.blah.MyBean
   CLASS CAST 
  EXCEPTION!
  
  So, the attribute is present in the request 
  object, it is not an instance of 'com.blah.blah.MyBean'; but the object's 
  class name is 'com.blah.blah.MyBean'. Does anyone have an idea what is 
  going on? How canthe object's class name be 'com.blah.blah.MyBean' 
  but not be able to cast to 'com.blah.blah.MyBean'?
  
  Thanks in advance!
  
  Leon 
Palermo

Important:

Internet communications are not necessarily secure and may be intercepted or changed after they are sent.
The Abbey National Group does not accept liability for any such changes. If you wish to confirm the origin or content of this communication, please contact the sender using an alternative means of communication.

This communication does not create or modify any contract.

If you are not the intended recipient of this communication you should destroy it without copying, disclosing or otherwise using its contents. Please notify the sender immediately of the error.

The Abbey National Group comprises Abbey National plc and its subsidiary group of companies.

Abbey National plc. Registered Office: Abbey House, Baker Street, London, NW1 6XL. Reg. No. 2294747.
Registered in England.



Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Leon Palermo
Title: Re: problems installing tomcat on linux



Yes,but Ineed to cast it to use the 
Bean specific functionality and...

 (com.blah.blah.MyBean)request.getAttribute("thename");

...causes the ClassCastException to 
occur.


  - Original Message - 
  From: 
  Bhat, Mahesh 
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 2001 9:11 AM
  Subject: RE: (EXPERTS ONLY) Bean Creation 
  in Dispatch Servlet
  
  Hi
  
  Have you tried 
  the simple way of :
  
  com.blah.blah.MyBean abean = new 
  com.blah.blah.MyBean();request.setAttribute("thename", 
  abean);
  
  in JSP : 
  com.blah.blah.MyBean abean = 
  request.getAttribute("thename");
  
  regards
  mahesh
  
  
  
-Original Message-From: Leon Palermo 
[mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:02 
PMTo: [EMAIL PROTECTED]Subject: 
(EXPERTS ONLY) Bean Creation in Dispatch Servlet
Hello All,

Let me preface this email by saying that I only 
put 'EXPERTS ONLY' so you hot shot programmers would actually read this 
email. If you are reading this, it worked!

I have an odd problem that I was hoping someone 
could help with.

I have a servlet that all jsps in the system 
are dispatched from. I create a bean in this servlet and add it to the 
request object like so...

 com.blah.blah.MyBean abean = 
(com.blah.blah.MyBean) 
Beans.instantiate(this.getClass().getClassLoader(),"com.blah.blah.MyBean"); 
...
 
request.setAttribute("thename", 
abean); 

I have also tried this to create the 
bean

 com.blah.blah.MyBean abean = 
new com.blah.blah.MyBean();

and also tried to place the object in the request like 
so

 
pageContext.setAttribute("thename", abean, 
PageContext.REQUEST_SCOPE);

Anywho, I then have the following in my jsp 
page...

 jsp:useBean id="thename" 
scope="request" class="com.blah.blah.MyBean" /

I get a java.lang.ClassCastException from the 
jsp. So, I decided to do a little error hunting ina jsp using 
the following code...

%try{ 
System.out.println(request.getAttribute("thename") == null);
 
System.out.println(request.getAttribute("thename") instanceof 
com.blah.blah.MyBean); 
System.out.println(request.getAttribute("thename").getClass().getName()); 
System.out.println(zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thename"));
}catch (ClassCastException 
e){ System.out.println("CLASS CAST 
EXCEPTION!");}%

The results of the code is as 
follows:

 false
 false
 
com.blah.blah.MyBean
 CLASS CAST 
EXCEPTION!

So, the attribute is present in the request 
object, it is not an instance of 'com.blah.blah.MyBean'; but the object's 
class name is 'com.blah.blah.MyBean'. Does anyone have an idea what is 
going on? How canthe object's class name be 
'com.blah.blah.MyBean' but not be able to cast to 
'com.blah.blah.MyBean'?

Thanks in advance!

Leon PalermoImportant:Internet communications are not necessarily 
  secure and may be intercepted or changed after they are sent.The Abbey 
  National Group does not accept liability for any such changes. If you wish to 
  confirm the origin or content of this communication, please contact the sender 
  using an alternative means of communication.This communication does 
  not create or modify any contract.If you are not the intended 
  recipient of this communication you should destroy it without copying, 
  disclosing or otherwise using its contents. Please notify the sender 
  immediately of the error.The Abbey National Group comprises Abbey 
  National plc and its subsidiary group of companies.Abbey National plc. 
  Registered Office: Abbey House, Baker Street, London, NW1 6XL. Reg. No. 
  2294747.Registered in England.


RE: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Bhat, Mahesh
Title: Re: problems installing tomcat on linux



Can you send the 
example code ?



  -Original Message-From: Leon Palermo 
  [mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:21 
  PMTo: [EMAIL PROTECTED]Subject: Re: 
  (EXPERTS ONLY) Bean Creation in Dispatch Servlet
  Yes,but Ineed to cast it to use the 
  Bean specific functionality and...
  
   (com.blah.blah.MyBean)request.getAttribute("thename");
  
  ...causes the ClassCastException to 
  occur.
  
  
- Original Message - 
From: 
Bhat, Mahesh 
To: [EMAIL PROTECTED] 

Sent: Friday, May 25, 2001 9:11 
AM
    Subject: RE: (EXPERTS ONLY) Bean 
    Creation in Dispatch Servlet

Hi

Have you 
tried the simple way of :

com.blah.blah.MyBean abean = new 
com.blah.blah.MyBean();request.setAttribute("thename", 
abean);

in JSP : 
com.blah.blah.MyBean abean = 
request.getAttribute("thename");

regards
mahesh



  -Original Message-From: Leon Palermo 
  [mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:02 
  PMTo: [EMAIL PROTECTED]Subject: 
  (EXPERTS ONLY) Bean Creation in Dispatch Servlet
  Hello All,
  
  Let me preface this email by saying that I 
  only put 'EXPERTS ONLY' so you hot shot programmers would actually read 
  this email. If you are reading this, it worked!
  
  I have an odd problem that I was hoping 
  someone could help with.
  
  I have a servlet that all jsps in the system 
  are dispatched from. I create a bean in this servlet and add it to 
  the request object like so...
  
   com.blah.blah.MyBean abean 
  = (com.blah.blah.MyBean) 
  Beans.instantiate(this.getClass().getClassLoader(),"com.blah.blah.MyBean"); 
  ...
   
  request.setAttribute("thename", 
  abean); 
  
  I have also tried this to create the 
  bean
  
   com.blah.blah.MyBean abean 
  = new com.blah.blah.MyBean();
  
  and also tried to place the object in the request like 
  so
  
   
  pageContext.setAttribute("thename", abean, 
  PageContext.REQUEST_SCOPE);
  
  Anywho, I then have the following in my jsp 
  page...
  
   jsp:useBean 
  id="thename" scope="request" class="com.blah.blah.MyBean" 
  /
  
  I get a java.lang.ClassCastException from the 
  jsp. So, I decided to do a little error hunting ina jsp using 
  the following code...
  
  %try{ 
  System.out.println(request.getAttribute("thename") == null);
   
  System.out.println(request.getAttribute("thename") instanceof 
  com.blah.blah.MyBean); 
  System.out.println(request.getAttribute("thename").getClass().getName()); 
  System.out.println(zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thename"));
  }catch (ClassCastException 
  e){ System.out.println("CLASS CAST 
  EXCEPTION!");}%
  
  The results of the code is as 
  follows:
  
   false
   false
   
  com.blah.blah.MyBean
   CLASS CAST 
  EXCEPTION!
  
  So, the attribute is present in the request 
  object, it is not an instance of 'com.blah.blah.MyBean'; but the object's 
  class name is 'com.blah.blah.MyBean'. Does anyone have an idea what 
  is going on? How canthe object's class name be 
  'com.blah.blah.MyBean' but not be able to cast to 
  'com.blah.blah.MyBean'?
  
  Thanks in advance!
  
  Leon 
PalermoImportant:Internet communications are not necessarily 
secure and may be intercepted or changed after they are sent.The Abbey 
National Group does not accept liability for any such changes. If you wish 
to confirm the origin or content of this communication, please contact the 
sender using an alternative means of communication.This 
communication does not create or modify any contract.If you are not 
the intended recipient of this communication you should destroy it without 
copying, disclosing or otherwise using its contents. Please notify the 
sender immediately of the error.The Abbey National Group comprises 
Abbey National plc and its subsidiary group of companies.Abbey 
National plc. Registered Office: Abbey House, Baker Street, London, NW1 6XL. 
Reg. No. 2294747.Registered in 
England.


Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Leon Palermo
Title: Re: problems installing tomcat on linux



Here is a very scaled down version of the dispatch 
servlet. Switch the name of the bean ('com.blah.blah.AnyCustomBean') in the jsp 
and servlet to any custom bean you wish to try out.

Create a .jsp page for the servlet to 
forwardthe request tothat looks something like this:

%@ page session="false" errorPage="error.jsp" 
%%@ page import = "com.blah.blah.AnyCustomBean" %

%try{ 
System.out.println((request.getAttribute("thebean") == 
null)); 
System.out.println((request.getAttribute("thebean") instanceof 
zedak.docworx.jspsupport.beans.BrandBean)); 
System.out.println((request.getAttribute("thebean").getClass().getName())); 
System.out.println((zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thebean")); 
}catch (ClassCastException e){ 
System.out.println("CLASS CAST EXCEPTION!"); }%

jsp:useBean id="thebean" scope="request" 
class="com.blah.blah.AnyCustomBean" /

Change the name of the jsp file in the servlet to 
match the .jsp file name you created above.

Thanks!

Leon

  - Original Message ----- 
  From: 
  Bhat, Mahesh 
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 2001 9:20 AM
  Subject: RE: (EXPERTS ONLY) Bean Creation 
  in Dispatch Servlet
  
  Can you send 
  the example code ?
  
  
  
-Original Message-From: Leon Palermo 
[mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:21 
PMTo: [EMAIL PROTECTED]Subject: 
Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet
Yes,but Ineed to cast it to use the 
Bean specific functionality and...

 (com.blah.blah.MyBean)request.getAttribute("thename");

...causes the ClassCastException to 
occur.


  - Original Message - 
  From: 
      Bhat, Mahesh 
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 2001 
  9:11 AM
  Subject: RE: (EXPERTS ONLY) 
  Bean Creation in Dispatch Servlet
  
  Hi
  
  Have you 
  tried the simple way of :
  
  com.blah.blah.MyBean abean = new 
  com.blah.blah.MyBean();request.setAttribute("thename", 
  abean);
  
  in JSP : 
  com.blah.blah.MyBean abean = 
  request.getAttribute("thename");
  
  regards
  mahesh
  
  
  
-Original Message-From: Leon Palermo 
[mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:02 
PMTo: [EMAIL PROTECTED]Subject: 
(EXPERTS ONLY) Bean Creation in Dispatch Servlet
Hello All,

Let me preface this email by saying that I 
only put 'EXPERTS ONLY' so you hot shot programmers would actually read 
this email. If you are reading this, it worked!

I have an odd problem that I was hoping 
someone could help with.

I have a servlet that all jsps in the 
system are dispatched from. I create a bean in this servlet and 
add it to the request object like so...

 com.blah.blah.MyBean 
abean = (com.blah.blah.MyBean) 
Beans.instantiate(this.getClass().getClassLoader(),"com.blah.blah.MyBean"); 
...
 
request.setAttribute("thename", 
abean); 

I have also tried this to create the 
bean

 com.blah.blah.MyBean 
abean = new com.blah.blah.MyBean();

and also tried to place the object in the request like 
so

 
pageContext.setAttribute("thename", abean, 
PageContext.REQUEST_SCOPE);

Anywho, I then have the following in my jsp 
page...

 jsp:useBean 
id="thename" scope="request" class="com.blah.blah.MyBean" 
/

I get a java.lang.ClassCastException from 
the jsp. So, I decided to do a little error hunting ina jsp 
using the following code...

%try{ 
System.out.println(request.getAttribute("thename") == 
null);
 
System.out.println(request.getAttribute("thename") instanceof 
com.blah.blah.MyBean); 
System.out.println(request.getAttribute("thename").getClass().getName()); 
System.out.println(zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thename"));
}catch (ClassCastException 
e){ System.out.println("CLASS CAST 
EXCEPTION!");}%

The results of the code is as 
follows:

 false
 false
 
com.blah.blah.MyBean
 CLASS CAST 
EXCEPTION!

So, the attribute is present in the request 
object, it is not an instance of 'com.blah.bla

Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Leon Palermo
Title: Re: problems installing tomcat on linux



Mahesh,

One more thing, in the servlet the 
line...

 thebean = 
(com.blah.blah.AnyCustomBean) 
Beans.instantiate(this.getClass().getClassLoader(), 
"com.blah.blah.AnyCustomBean");

...needs to have a try/catch block around it for a 
ClassNotFoundException.

Leon

  - Original Message - 
  From: 
  Leon Palermo 
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 2001 9:48 AM
  Subject: Re: (EXPERTS ONLY) Bean Creation 
  in Dispatch Servlet
  
  Here is a very scaled down version of the 
  dispatch servlet. Switch the name of the bean ('com.blah.blah.AnyCustomBean') 
  in the jsp and servlet to any custom bean you wish to try out.
  
  Create a .jsp page for the servlet to 
  forwardthe request tothat looks something like this:
  
  %@ page session="false" errorPage="error.jsp" 
  %%@ page import = "com.blah.blah.AnyCustomBean" %
  
  %try{ 
  System.out.println((request.getAttribute("thebean") == 
  null)); 
  System.out.println((request.getAttribute("thebean") instanceof 
  zedak.docworx.jspsupport.beans.BrandBean)); 
  System.out.println((request.getAttribute("thebean").getClass().getName())); 
  System.out.println((zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thebean")); 
  }catch (ClassCastException e){ 
  System.out.println("CLASS CAST EXCEPTION!"); }%
  
  jsp:useBean id="thebean" scope="request" 
  class="com.blah.blah.AnyCustomBean" /
  
  Change the name of the jsp file in the servlet to 
  match the .jsp file name you created above.
  
  Thanks!
  
  Leon
  
- Original Message - 
    From: 
Bhat, Mahesh 
To: [EMAIL PROTECTED] 

Sent: Friday, May 25, 2001 
9:20 AM
Subject: RE: (EXPERTS ONLY) 
Bean Creation in Dispatch Servlet

Can you send 
the example code ?



  -Original Message-From: Leon Palermo 
      [mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:21 
  PMTo: [EMAIL PROTECTED]Subject: 
  Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet
  Yes,but Ineed to cast it to use 
  the Bean specific functionality and...
  
   (com.blah.blah.MyBean)request.getAttribute("thename");
  
  ...causes the ClassCastException to 
  occur.
  
  
- Original Message - 

From: 
        Bhat, Mahesh 
    To: [EMAIL PROTECTED] 
    
Sent: Friday, May 25, 2001 
9:11 AM
Subject: RE: (EXPERTS 
ONLY) Bean Creation in Dispatch Servlet

Hi

Have you 
tried the simple way of :

com.blah.blah.MyBean abean = new 
com.blah.blah.MyBean();request.setAttribute("thename", 
abean);

in JSP : 
com.blah.blah.MyBean abean = 
request.getAttribute("thename");

regards
mahesh



  -Original Message-From: Leon Palermo 
  [mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:02 
  PMTo: [EMAIL PROTECTED]Subject: 
  (EXPERTS ONLY) Bean Creation in Dispatch Servlet
  Hello All,
  
  Let me preface this email by saying that 
  I only put 'EXPERTS ONLY' so you hot shot programmers would actually 
  read this email. If you are reading this, it 
worked!
  
  I have an odd problem that I was hoping 
  someone could help with.
  
  I have a servlet that all jsps in the 
  system are dispatched from. I create a bean in this servlet and 
  add it to the request object like so...
  
   com.blah.blah.MyBean 
  abean = (com.blah.blah.MyBean) 
  Beans.instantiate(this.getClass().getClassLoader(),"com.blah.blah.MyBean"); 
  ...
   
  request.setAttribute("thename", 
  abean); 
  
  I have also tried this to create the 
  bean
  
   com.blah.blah.MyBean 
  abean = new com.blah.blah.MyBean();
  
  and also tried to place the object in the request like 
  so
  
   
  pageContext.setAttribute("thename", abean, 
  PageContext.REQUEST_SCOPE);
  
  Anywho, I then have the following in my 
  jsp page...
  
   jsp:useBean 
  id="thename" scope="request" class="com.blah.blah.MyBean" 
  /
  
  I get a java.lang.ClassCastException from 
  the jsp. So, I decided to do a little error hunting ina 
  jsp using the following code...
  
  %try{ 
  System.out.println(request.getAttribute("thename")

Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Leon Palermo
Title: Re: problems installing tomcat on linux



Darn it all!

The jsp should look like this. I forgot to 
take my own class name out of a few lines.

%try{ 
System.out.println((request.getAttribute("thebean") == 
null)); 
System.out.println((request.getAttribute("thebean") instanceof 
com.blah.blah.AnyCustomBean)); 
System.out.println((request.getAttribute("thebean").getClass().getName())); 
System.out.println((com.blah.blah.AnyCustomBean)request.getAttribute("thebean")); 
}catch (ClassCastException e){ 
System.out.println("CLASS CAST EXCEPTION!"); }%

  - Original Message - 
  From: 
  Leon Palermo 
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 2001 9:53 AM
  Subject: Re: (EXPERTS ONLY) Bean Creation 
  in Dispatch Servlet
  
  Mahesh,
  
  One more thing, in the servlet the 
  line...
  
   thebean = 
  (com.blah.blah.AnyCustomBean) 
  Beans.instantiate(this.getClass().getClassLoader(), 
  "com.blah.blah.AnyCustomBean");
  
  ...needs to have a try/catch block around it for 
  a ClassNotFoundException.
  
  Leon
  
- Original Message - 
From: 
Leon Palermo 

To: [EMAIL PROTECTED] 
    
    Sent: Friday, May 25, 2001 
    9:48 AM
    Subject: Re: (EXPERTS ONLY) 
Bean Creation in Dispatch Servlet

Here is a very scaled down version of the 
dispatch servlet. Switch the name of the bean 
('com.blah.blah.AnyCustomBean') in the jsp and servlet to any custom bean 
you wish to try out.

Create a .jsp page for the servlet to 
forwardthe request tothat looks something like 
this:

%@ page session="false" 
errorPage="error.jsp" %%@ page import = 
"com.blah.blah.AnyCustomBean" %

%try{ 
System.out.println((request.getAttribute("thebean") == 
null)); 
System.out.println((request.getAttribute("thebean") instanceof 
zedak.docworx.jspsupport.beans.BrandBean)); 
System.out.println((request.getAttribute("thebean").getClass().getName())); 
System.out.println((zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thebean")); 
}catch (ClassCastException e){ 
System.out.println("CLASS CAST EXCEPTION!"); 
}%

jsp:useBean id="thebean" scope="request" 
class="com.blah.blah.AnyCustomBean" /

Change the name of the jsp file in the servlet 
to match the .jsp file name you created above.

Thanks!

Leon
    
      - Original Message - 
  From: 
  Bhat, Mahesh 
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 2001 
  9:20 AM
  Subject: RE: (EXPERTS ONLY) 
  Bean Creation in Dispatch Servlet
  
  Can you 
  send the example code ?
  
  
  
        -Original Message-----From: Leon Palermo 
[mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:21 
PMTo: [EMAIL PROTECTED]Subject: 
Re: (EXPERTS ONLY) Bean Creation in Dispatch 
Servlet
Yes,but Ineed to cast it to use 
the Bean specific functionality and...

 (com.blah.blah.MyBean)request.getAttribute("thename");

...causes the ClassCastException to 
occur.


  - Original Message ----- 
      
  From: 
  Bhat, Mahesh 
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 
  2001 9:11 AM
  Subject: RE: (EXPERTS 
  ONLY) Bean Creation in Dispatch Servlet
  
  Hi
  
  Have 
  you tried the simple way of :
  
  com.blah.blah.MyBean abean = new 
  com.blah.blah.MyBean();request.setAttribute("thename", 
  abean);
  
  in JSP : 
  com.blah.blah.MyBean abean = 
  request.getAttribute("thename");
  
  regards
  mahesh
  
  
  
-Original Message-From: Leon Palermo 
[mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:02 
PMTo: [EMAIL PROTECTED]Subject: 
(EXPERTS ONLY) Bean Creation in Dispatch 
Servlet
Hello All,

Let me preface this email by saying 
that I only put 'EXPERTS ONLY' so you hot shot programmers would 
actually read this email. If you are reading this, it 
worked!

I have an odd problem that I was hoping 
someone could help with.

I have a servlet that all jsps in the 
system are dispatched from. I create a bean in this servlet 
and add it to the request object like so...

 com.blah.blah.MyBean 
abean = (com.blah.blah.MyBean) 
Beans.instantiate(this.getClas

Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Leon Palermo
Title: Re: problems installing tomcat on linux



Mahesh and others,

After performing the test myselfand looking 
at things, I found out that indeed the dispatch servlet is putting the bean in 
correctly and the jsps areutilizing them properly. The problem 
occurs only after I compile any file used by the Bean. Although the Bean 
isn't compiled itself (the .class file remains the same); the compilation of a 
classimported by the bean causes the ClassCastException. Only after 
restarting tomcat do things function properly until the next compilation of the 
file used by the Bean.

As a result, I transfer the focus of this problem 
away from the jsp realm to the Java language realm. Does anyone have any 
idea why the compilation of imported classes would cause a ClassCastException as 
previously described?

Thanks again!

Leon

  - Original Message - 
  From: 
  Leon Palermo 
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 2001 9:56 AM
  Subject: Re: (EXPERTS ONLY) Bean Creation 
  in Dispatch Servlet
  
  Darn it all!
  
  The jsp should look like this. I forgot to 
  take my own class name out of a few lines.
  
  %try{ 
  System.out.println((request.getAttribute("thebean") == 
  null)); 
  System.out.println((request.getAttribute("thebean") instanceof 
  com.blah.blah.AnyCustomBean)); 
  System.out.println((request.getAttribute("thebean").getClass().getName())); 
  System.out.println((com.blah.blah.AnyCustomBean)request.getAttribute("thebean")); 
  }catch (ClassCastException e){ 
  System.out.println("CLASS CAST EXCEPTION!"); }%
  
- Original Message - 
From: 
Leon Palermo 

To: [EMAIL PROTECTED] 

    Sent: Friday, May 25, 2001 9:53 
AM
Subject: Re: (EXPERTS ONLY) Bean 
Creation in Dispatch Servlet

Mahesh,

One more thing, in the servlet the 
line...

 thebean = 
(com.blah.blah.AnyCustomBean) 
Beans.instantiate(this.getClass().getClassLoader(), 
"com.blah.blah.AnyCustomBean");

...needs to have a try/catch block around it 
for a ClassNotFoundException.

Leon

  - Original Message - 
  From: 
  Leon Palermo 
  
  To: [EMAIL PROTECTED] 
  
      Sent: Friday, May 25, 2001 
  9:48 AM
  Subject: Re: (EXPERTS ONLY) 
  Bean Creation in Dispatch Servlet
  
  Here is a very scaled down version of the 
  dispatch servlet. Switch the name of the bean 
  ('com.blah.blah.AnyCustomBean') in the jsp and servlet to any custom bean 
  you wish to try out.
  
  Create a .jsp page for the servlet to 
  forwardthe request tothat looks something like 
  this:
  
  %@ page session="false" 
  errorPage="error.jsp" %%@ page import = 
  "com.blah.blah.AnyCustomBean" %
  
  %try{ 
  System.out.println((request.getAttribute("thebean") == 
  null)); 
  System.out.println((request.getAttribute("thebean") instanceof 
  zedak.docworx.jspsupport.beans.BrandBean)); 
  System.out.println((request.getAttribute("thebean").getClass().getName())); 
  System.out.println((zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thebean")); 
  }catch (ClassCastException e){ 
  System.out.println("CLASS CAST EXCEPTION!"); 
  }%
  
  jsp:useBean id="thebean" scope="request" 
  class="com.blah.blah.AnyCustomBean" /
  
  Change the name of the jsp file in the 
  servlet to match the .jsp file name you created above.
  
  Thanks!
  
  Leon
  
- Original Message - 
    
    From: 
    Bhat, Mahesh 
To: [EMAIL PROTECTED] 

Sent: Friday, May 25, 2001 
9:20 AM
Subject: RE: (EXPERTS 
ONLY) Bean Creation in Dispatch Servlet

Can you 
send the example code ?



  -----Original Message-From: Leon Palermo 
  [mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:21 
  PMTo: [EMAIL PROTECTED]Subject: 
  Re: (EXPERTS ONLY) Bean Creation in Dispatch 
  Servlet
  Yes,but Ineed to cast it to 
  use the Bean specific functionality and...
  
   (com.blah.blah.MyBean)request.getAttribute("thename");
  
  ...causes the ClassCastException to 
  occur.
  
  
- Original Message - 
    
    From: 
    Bhat, Mahesh 

    To: [EMAIL PROTECTED] 

Sent: Friday, May 25, 
2001 9:11 AM
Subject: RE: (EXPERTS 
ONLY) Bean Creation in Dispatch Servlet

Hi

Have 
you tried the simple way of 

RE: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Bhat, Mahesh
Title: Re: problems installing tomcat on linux



Hi 
Leon.

I did try what 
you said and it works perfect for me. I am attaching all the files used by me, 
Check them out.

regards
mahesh



  -Original Message-From: Leon Palermo 
  [mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 3:39 
  PMTo: [EMAIL PROTECTED]Subject: Re: 
  (EXPERTS ONLY) Bean Creation in Dispatch Servlet
  Mahesh and others,
  
  After performing the test myselfand looking 
  at things, I found out that indeed the dispatch servlet is putting the bean in 
  correctly and the jsps areutilizing them properly. The problem 
  occurs only after I compile any file used by the Bean. Although the Bean 
  isn't compiled itself (the .class file remains the same); the compilation of a 
  classimported by the bean causes the ClassCastException. Only 
  after restarting tomcat do things function properly until the next compilation 
  of the file used by the Bean.
  
  As a result, I transfer the focus of this problem 
  away from the jsp realm to the Java language realm. Does anyone have any 
  idea why the compilation of imported classes would cause a ClassCastException 
  as previously described?
  
  Thanks again!
  
  Leon
  
- Original Message - 
From: 
Leon Palermo 

To: [EMAIL PROTECTED] 

Sent: Friday, May 25, 2001 9:56 
AM
Subject: Re: (EXPERTS ONLY) Bean 
Creation in Dispatch Servlet

Darn it all!

The jsp should look like this. I forgot 
to take my own class name out of a few lines.

%try{ 
System.out.println((request.getAttribute("thebean") == 
null)); 
System.out.println((request.getAttribute("thebean") instanceof 
com.blah.blah.AnyCustomBean)); 
System.out.println((request.getAttribute("thebean").getClass().getName())); 
System.out.println((com.blah.blah.AnyCustomBean)request.getAttribute("thebean")); 
}catch (ClassCastException e){ 
System.out.println("CLASS CAST EXCEPTION!"); 
}%

  - Original Message - 
  From: 
  Leon Palermo 
  
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 2001 9:53 
  AM
  Subject: Re: (EXPERTS ONLY) Bean 
  Creation in Dispatch Servlet
  
  Mahesh,
  
  One more thing, in the servlet the 
  line...
  
   thebean = 
  (com.blah.blah.AnyCustomBean) 
  Beans.instantiate(this.getClass().getClassLoader(), 
  "com.blah.blah.AnyCustomBean");
  
  ...needs to have a try/catch block around it 
  for a ClassNotFoundException.
  
  Leon
  
- Original Message - 

From: 
Leon Palermo 

To: [EMAIL PROTECTED] 

Sent: Friday, May 25, 2001 
    9:48 AM
    Subject: Re: (EXPERTS 
ONLY) Bean Creation in Dispatch Servlet

Here is a very scaled down version of the 
dispatch servlet. Switch the name of the bean 
('com.blah.blah.AnyCustomBean') in the jsp and servlet to any custom 
bean you wish to try out.

Create a .jsp page for the servlet to 
forwardthe request tothat looks something like 
this:

%@ page session="false" 
errorPage="error.jsp" %%@ page import = 
"com.blah.blah.AnyCustomBean" %

%try{ 
System.out.println((request.getAttribute("thebean") == 
null)); 
System.out.println((request.getAttribute("thebean") instanceof 
zedak.docworx.jspsupport.beans.BrandBean)); 
System.out.println((request.getAttribute("thebean").getClass().getName())); 
System.out.println((zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thebean")); 
}catch (ClassCastException e){ 
System.out.println("CLASS CAST EXCEPTION!"); 
}%

jsp:useBean id="thebean" 
scope="request" class="com.blah.blah.AnyCustomBean" /

Change the name of the jsp file in the 
servlet to match the .jsp file name you created above.

Thanks!

Leon

  - Original Message - 
      
  From: 
      Bhat, Mahesh 
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 
  2001 9:20 AM
  Subject: RE: (EXPERTS 
  ONLY) Bean Creation in Dispatch Servlet
  
  Can you 
  send the example code ?
  
  
  
-Original Message-----From: Leon Palermo 
    [mailto:[EMAIL PROTECTED]]Sent: Friday, May 25, 2001 2:21 
PMTo: [EMAIL PROTECTED]Subject: 
Re: (EXPERTS ONLY) Bean Creation in Dispatch 
Servlet
Yes,but Ineed to cast it to 

Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Anne Dirkse

Hi Leon --

I had something similar happen, and it occours when I recompile the 
bean and then try to access it without restarting Tomcat.
My *guess* is that classes that are reloaded (when they have been 
loaded once then recompiled) have a different classloader.
Anyhow, restarting Tomcat has always resolved that problem for me.

Hope that helps.
Anne

 Leon Palermo wrote:
 
 Hello All,
 
 Let me preface this email by saying that I only put 'EXPERTS ONLY' so
 you hot shot programmers would actually read this email.  If you are
 reading this, it worked!
 
 I have an odd problem that I was hoping someone could help with.
 
 I have a servlet that all jsps in the system are dispatched from.  I
 create a bean in this servlet and add it to the request object like
 so...
 
 com.blah.blah.MyBean abean = (com.blah.blah.MyBean)
 Beans.instantiate(this.getClass().getClassLoader(),com.blah.blah.MyBean);
 ...
 request.setAttribute(thename, abean);
 
 I have also tried this to create the bean
 
 com.blah.blah.MyBean abean = new com.blah.blah.MyBean();
 
 and also tried to place the object in the request like so
 
 pageContext.setAttribute(thename, abean,
 PageContext.REQUEST_SCOPE);
 
 Anywho, I then have the following in my jsp page...
 
 jsp:useBean id=thename scope=request
 class=com.blah.blah.MyBean /
 
 I get a java.lang.ClassCastException from the jsp.  So, I decided to
 do a little error hunting in a jsp using the following code...
 
 %try{
 System.out.println(request.getAttribute(thename) == null);
 System.out.println(request.getAttribute(thename) instanceof
 com.blah.blah.MyBean);
 
 System.out.println(request.getAttribute(thename).getClass().getName());
 
 
System.out.println(zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute(thename));
 }catch (ClassCastException e){
 System.out.println(CLASS CAST EXCEPTION!);
 }
 %
 
 The results of the code is as follows:
 
 false
 false
 com.blah.blah.MyBean
 CLASS CAST EXCEPTION!
 
 So, the attribute is present in the request object, it is not an
 instance of 'com.blah.blah.MyBean'; but the object's class name is
 'com.blah.blah.MyBean'.  Does anyone have an idea what is going on?
 How can the object's class name be 'com.blah.blah.MyBean' but not be
 able to cast to 'com.blah.blah.MyBean'?
 
 Thanks in advance!
 
 Leon Palermo



Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread anil

I am not an expert.
Every call has some kind of static class ID for the versioning. When you
compile a class,  it  increments. So you have your jsp/servlet compiled
as one class id (you have reference from servlet/jsp to bean) , if you
recompile your bean, then it is going to increment class id and you do
have versioning mismatch. I have seen this happens on RMI.

anil.

Leon Palermo wrote:

  Mahesh and others, After performing the test myself and looking at
 things, I found out that indeed the dispatch servlet is putting the
 bean in correctly and the jsps are utilizing them properly.  The
 problem occurs only after I compile any file used by the Bean.
 Although the Bean isn't compiled itself (the .class file remains the
 same); the compilation of a class imported by the bean causes the
 ClassCastException.  Only after restarting tomcat do things function
 properly until the next compilation of the file used by the Bean. As a
 result, I transfer the focus of this problem away from the jsp realm
 to the Java language realm.  Does anyone have any idea why the
 compilation of imported classes would cause a ClassCastException as
 previously described? Thanks again!




Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Guido Medina
Title: Re: problems installing tomcat on linux



Excuse me, you have this: 

 
System.out.println(zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thename"));

before the catch statement, one question: Did you 
check very well what you wrote in that line ?

Guido.

  - Original Message - 
  From: 
  Leon Palermo 
  To: [EMAIL PROTECTED] 
  
  Sent: Friday, May 25, 2001 9:01 AM
  Subject: (EXPERTS ONLY) Bean Creation in 
  Dispatch Servlet
  
  Hello All,
  
  Let me preface this email by saying that I only 
  put 'EXPERTS ONLY' so you hot shot programmers would actually read this 
  email. If you are reading this, it worked!
  
  I have an odd problem that I was hoping someone 
  could help with.
  
  I have a servlet that all jsps in the system are 
  dispatched from. I create a bean in this servlet and add it to the 
  request object like so...
  
   com.blah.blah.MyBean abean = 
  (com.blah.blah.MyBean) 
  Beans.instantiate(this.getClass().getClassLoader(),"com.blah.blah.MyBean"); 
  ...
   
  request.setAttribute("thename", 
  abean); 
  
  I have also tried this to create the 
  bean
  
   com.blah.blah.MyBean abean = 
  new com.blah.blah.MyBean();
  
  and also tried to place the object in the request like 
so
  
   
  pageContext.setAttribute("thename", abean, 
  PageContext.REQUEST_SCOPE);
  
  Anywho, I then have the following in my jsp 
  page...
  
   jsp:useBean id="thename" 
  scope="request" class="com.blah.blah.MyBean" /
  
  I get a java.lang.ClassCastException from the 
  jsp. So, I decided to do a little error hunting ina jsp using the 
  following code...
  
  %try{ 
  System.out.println(request.getAttribute("thename") == null);
   
  System.out.println(request.getAttribute("thename") instanceof 
  com.blah.blah.MyBean); 
  System.out.println(request.getAttribute("thename").getClass().getName()); 
  System.out.println(zedak.docworx.jspsupport.beans.BrandBean)request.getAttribute("thename"));
  }catch (ClassCastException 
  e){ System.out.println("CLASS CAST 
  EXCEPTION!");}%
  
  The results of the code is as 
  follows:
  
   false
   false
   
  com.blah.blah.MyBean
   CLASS CAST 
  EXCEPTION!
  
  So, the attribute is present in the request 
  object, it is not an instance of 'com.blah.blah.MyBean'; but the object's 
  class name is 'com.blah.blah.MyBean'. Does anyone have an idea what is 
  going on? How canthe object's class name be 'com.blah.blah.MyBean' 
  but not be able to cast to 'com.blah.blah.MyBean'?
  
  Thanks in advance!
  
  Leon 
Palermo


Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Milt Epstein

On Fri, 25 May 2001, Leon Palermo wrote:

 -Original Message-
 From: Leon Palermo [mailto:[EMAIL PROTECTED]]
 Sent: Friday, May 25, 2001 2:02 PM
 To: [EMAIL PROTECTED]
 Subject: (EXPERTS ONLY) Bean Creation in Dispatch Servlet


 Hello All,

 Let me preface this email by saying that I only put 'EXPERTS ONLY'
 so you hot shot programmers would actually read this email.  If you
 are reading this, it worked!
[ ... ]

What if we stopped reading it here?

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]




Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Leon Palermo

Clearly then you would not be the expert I was looking for :)

Leon

 
 
  Hello All,
 
  Let me preface this email by saying that I only put 'EXPERTS ONLY'
  so you hot shot programmers would actually read this email.  If you
  are reading this, it worked!
 [ ... ]
 
 What if we stopped reading it here?
 
 Milt Epstein
 Research Programmer
 Software/Systems Development Group
 Computing and Communications Services Office (CCSO)
 University of Illinois at Urbana-Champaign (UIUC)
 [EMAIL PROTECTED]




RE: (EXPERTS ONLY) Bean Creation in Dispatch Servlet

2001-05-25 Thread Kyle Burke

LOL! now that's rich!

-Original Message-
From: Leon Palermo [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 25, 2001 2:25 PM
To: [EMAIL PROTECTED]
Subject: Re: (EXPERTS ONLY) Bean Creation in Dispatch Servlet


Clearly then you would not be the expert I was looking for :)

Leon

 
 
  Hello All,
 
  Let me preface this email by saying that I only put 'EXPERTS ONLY'
  so you hot shot programmers would actually read this email.  If you
  are reading this, it worked!
 [ ... ]
 
 What if we stopped reading it here?
 
 Milt Epstein
 Research Programmer
 Software/Systems Development Group
 Computing and Communications Services Office (CCSO)
 University of Illinois at Urbana-Champaign (UIUC)
 [EMAIL PROTECTED]