Solved

Array required, but java.sql.Array found

Posted on 2010-08-24
6
488 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ajax auto save 15 93
Javascript onclick event 4 101
library class in java 1 89
mask rule in struts validation.xml 5 70
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now