• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Client and Server side object access

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I recently had a topic submitted to this forum (Sept 17th, 2002 Subject: ClassCastException problem).
The following is an extract:
I have a bean called Body which is in a package
com.test.config.model.bean. It consists of three
private strings and their getter and setter methods.
I also have a class called Container which is in a package com.test.server.
This class has a getBodyContainer method which returns a vector of Bodys.
I also have a servlet called Test which is in a package
called com.test.config.controller.servlet
Test instantiates a Container object and calls the getBodyContainer method. i.e.
Vector bodys = container.getBodyContainer();
for (int i = 0; i < bodys.size(); i++)
{
Object object = bodys.elementAt(i);
Body body = (Body) object;
}
I get a class cast exception on the line:
Body body = (Body) object;
Why does this happen ?
I have now fixed the problem but I am still confused.
I had both client and server classes in my classpath.
I am using Jakarta Tomcat 4.0 as my servlet engine.
All of the classes mentioned above are on the server side except for the body class whose class file was on the client side.
When I moved it from the client to the server side the ClassCastException dissappeared.
Why does this movement resolve my problem ?
Is there a subtle difference between client and server side objects in how they are accessed ?
Any help would be greatly appreciated.
Regards,
Damian.
 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic