Change attributes from one Object to another

0

In my java application I have an object declared as Extrair extrair = new Extrair(); And I use this object and its attributes for my servlet. But I need to pass this object to .jsp. In the jsp I use extrair = request.getAttribute(); , only the request method returns an Object and I'm assigning an Object to an Extract.

How can I resolve this?

    
asked by anonymous 26.08.2014 / 05:23

1 answer

1

It indicates that you simply need to cast (as @mgibsonbr has indicated), however, to ensure that a ClassCastException is to verify that the object instance matches the class you are using:

Object attribute=request.getAttribute();
if(attribute instanceOf Extrair)
    extrair = attribute;
    
26.08.2014 / 14:47