• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Object type casting?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
I have a JSP page that is trying to access a requestScope variable.. When I try ${requestScope.answer} it gives me the object reference instead of the value. Sorry I'm new at this and I'm thinking its Java casting issue, any suggestions on how I can fix this would be appreciated!

Thanks!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What type of object does answer represent?
 
Nikki Agr
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the MVC paradigm, my View JSP takes a number from the user, forwards it to a Controller which parses it to an Integer and then pokes it into a certain java class that computes the resolution of that integer. I set that computed answer as an attribute:



where Resolver is the constructor.

Now when I try to access this attribute answer in the View by using ${requestScope.answer} it shows me something as model.Resolver@1716fa0 (where class Resolver is in the model package).

I'm not sure if this info is enough, as you can tell, I'm lost...
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is exactly what is to be expected if Resolver doesn't have a toString method that overrides the default. What did you expect to happen?

And more importantly, what is it you want to happen?

What is the purpose of Resolver?
[ November 09, 2008: Message edited by: Bear Bibeault ]
 
Nikki Agr
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose the number entered is 10, then the resolution is 5 2. So somehow I need to cast that object reference to some other data type.. When I try to parse it to String or Integer, it says it cannot do so.
 
Nikki Agr
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Bear, thanks for helping me out, I think I figured out the solution. You may close this topic. Have a nice day!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic