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
Solved

Array required, but java.sql.Array found

Posted on 2010-08-24
6
490 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 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