Array required, but java.sql.Array found

Posted on 2010-08-24
Last Modified: 2012-05-10

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();

      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

Question by:kishan66
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 40

Expert Comment

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);
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 33515239
have only one value
so try this arrobj[0]);

Author Comment

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);

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
LVL 27

Accepted Solution

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

Assisted Solution

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[]'

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apache-Tomcat Single Sign On with NTLM/Kerberos on Windows 2008R2 3 274
caughtSpeeding java challenge 16 141
maven set up 2 207
listing all functions in JavaScript 19 248
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
Invest in your employees with these five simple steps to improve employee engagement and retention.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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