Solved

Array required, but java.sql.Array found

Posted on 2010-08-24
6
492 Views
Last Modified: 2012-05-10
Hi,

I am getting the Error at
"out.println("The object present is " + arrobj[1]);"

where ---------------------    
       
         Object[] obj;
        Object[] obj_sat3;

      obj_sat3 = ar2.toArray();
      obj = ar.toArray();

          session.setAttribute("obj1",obj);
      session.setAttribute("obj3",obj_sat3);
      Array arrobj = (Array)session.getAttribute("obj1");
        out.println("The object present is " + arrobj[1]);
------------------------------------------

but when i just use the obj object rather than session name "obj1" it works fine....
out.println("The object present is " + obj[1]);

Environment:-- JSP

thanks
0
Comment
Question by:kishan66
6 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33513476
can you print?
out.println("The object present is " + arrobj.getClass());
out.println("The object present is " + arrobj);
out.println("The object present is " + arrobj.length);
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 33515239
>>session.setAttribute("obj1",obj);
have only one value
so try this arrobj[0]);
 
0
 

Author Comment

by:kishan66
ID: 33516073
Hi Gurvinder,

I tried all the Print statements...

--first two throws nothing...empty string though i used simple text like..
 out.println("The object present is " + arrobj.getClass());
 out.println("The object present is " + arrobj);
 
 "I guess there is some problem with " 
Array arrobj = (Array)session.getAttribute("obj1");

--Third print statement
Error-- Variable length at
out.println("The object present is " + arrobj.length);

thanks
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 33516242
>>>>>>Error-- Variable length at
out.println("The object present is " + arrobj.length);

u cant find array length . u can find only size
0
 
LVL 27

Accepted Solution

by:
rrz earned 350 total points
ID: 33516743
>Array arrobj = (Array)session.getAttribute("obj1");
You set obj1 with  
session.setAttribute("obj1",obj);  
and you declared  
Object[] obj;  
Please try  using  
Object[] arrobj = (Object[])session.getAttribute("obj1");
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 150 total points
ID: 33518195
rather than type casting to Array type cast it to the same object which you have used in setting the attribute 'Object[]'
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Export JSON response data to Excel in IE9 3 89
caughtSpeeding java challenge 16 140
Handle form fields in spring mvc controller 1 70
junit example issue 2 22
Arrow Electronics was searching for a KVM  (Keyboard/Video/Mouse) switch that could display on one single monitor the current status of all units being tested on the rack.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question