How to store an array in a session

hi everyone
iam getting problem while storing an arrray in a session can any one help me thanks in advance

What kind of array is it?
You can store them in a session only if the objects in the array are serializable.

Similar Messages

  • Can any body tell me How to store string array in a array

    Can any body tell me How to store string array in a array

    YesNot quite sure what question you're answering but here's how to copy an array.// given a String[] strArr
    // pre Java 6
    String[] newStrArr = new String[strArr.length];
    System.arrayCopy(strArr, 0, newStrArr, 0, strArr.length);
    // post Java 6
    String[] newStrArr = Arrays.copyOf(strArr, strArr.length);Edit:
    Or in fact use clone() as mark pointed out.
    Message was edited by:
    dwg

  • How to store forms fields into the session ?

    Hi All,
    I have to store forms fields into the session.
    I have four forms (htm forms) in four jsps and there are total 25 fields.
    I am inserting all the fields into the database at once while user submit the last form.
    I want to use session to store forms fields.
    So please anybody tell me how to do that.
    Is the following code correct to store the forms fields into
    the sesstion........
    // creating a session
    HttpSession session=request.getSession(true);
    // retrieving form fields
    String name=request.getParameter("customer_name");
    String business=request.getParameter("business");
    String address=request.getParameter("address");
    and so on....
    // store form fields into the session
    session.setAttribute("name",name);
    session.setAttribute("business",business);
    session.setAttribute("address",address);
    and so on....
    and later on get the value as:
    session.getAttribute("name");
    session.getAttribute("business");
    session.getAttribute("address");
    and so on....
    OR
    is there another way to store form fields into the session.
    Please guide and reply with coding.....
    Please answer and help.
    Thanks
    Amitindia

    I don't mean to be an *** but I have no desire to help someone so unwilling to think >>and do. Go through some of these tutorial, do the examples in each and you will be far >>better equipped to ask questions:
    http://www.google.co.za/search?hl=en&q=%2Bjsp+%2Bjavabean+%2Btutorial&b >>tnG=Google+Search&meta=
    I was just asking that if I use the following
    <jsp:useBean id="cart" scope="session" class="session.Carts" />
    <jsp:setProperty name="cart" property="address" value="myaddress" />
    </jsp:useBean>then will I be able to acheive my aim as I have to store form fields into the session and later retreive while user submit the last form.
    Please read my question that I have posted.
    Am I using the right way................or which is the best way to store form fields into the session and later retrieve them.
    please reply
    Thanks
    Amitindia

  • How to store 2C array to a singl binary file

    Hi
    I have to store multiple waveforms output that is each 1D array to a single binary file. how do i do this.
    i can store 1D array to binary file and retrieve it by reading the binary file and plotting the waveform. but i am not able to store 2D array to the single file. how do store many 1D array in one binary file,
    Thank you. Hema

    (We would also need to know your LabVIEW version. If you have a very old version, things would be quite different.)
    As Smercurio_fc already mentioned, the option to "prepend array size" would make things much easier here, because then you would read it as a single 2D array.
    Here's how that would look like. This is probably the recommended solution, just for simplicity reasons.
    Not prepending the size is more useful if you write the data in increments, but later want to read it as one.
    Message Edited by altenbach on 11-15-2008 09:02 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SaveRestore2D.png ‏21 KB

  • I have problem how to store the array?

    for(i=0;i<empRec.length;i++)
              if(empRec.getCategory()=='F'||empRec[i].getCategory()=='H')
                   if(empRec[i].getCategory()=='F')
                   Movie interesting[]=new Movie[2];
                   interesting[i].setCategory('F');
                   System.out.println("Category:"+interesting[i].getCategory());
    has a exception like this Exception in thread "main" java.lang.NullPointerException
            at Movie_video.main(Movie_video.java:146)
    this is my part of the coding... i want ask how to Separate out the movie numbers of all the movies in the Fiction and Horror categories and store them in an array ?interesting?.
    Edited by: williamku87 on Mar 31, 2008 12:05 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    It seems the problem is situated in the line +interesting.setCategory('F');+
    You instantiated the array, but not the object within the array. A possible solution could be:
    for(i=0;i<empRec.length;i++)
              if(empRec.getCategory()=='F'||empRec[i].getCategory()=='H')
                   if(empRec=new Movie[2];
    interesting[i] = new Movie();
                   interesting[i].setCategory('F');
                   System.out.println("Category:"+interesting[i].getCategory());
    }But very unusual to add only one object to an array of 2. What are you aiming for using the array +interesting+?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to store complex data in session object

    Hi All,
            I have a requirement like this, I have to store some complex data(like some object) in webdynpro session object.
    I know that i can store some string value in session by using wdScopeUtil and is it possible to store some complex data like(object ot object array).
    See i have some ContryTO[] object which contains countrycode and value i have to store this Array object in session.How can I solve this problem,i am strucked regarding this pls help me regarding this issue.
    Regards,
    saleem

    Bala,
    Go thru this link. It may be useful to you.
    Maintaining caching for a user session in webdynpro
    List elementList = new ArrayList();
    // set values to your list.
    IMaintainScope maintainer = Utils.getScopeMaintainer(WDScopeType.APPLICATION_SCOPE);
    maintainer.getScope().put("list",elementList);
    List elementList1 = (List)maintainer.getScope().get("list");
    Regards,
    Sridhar

  • How to store the output of a analog to digital converter into an 2D array

    Hi
    I am doing my M.Tech Thesis in Image reconstruction and I am using labview for simulation and I want to know how to store the output of a analog to digital converter into an 2D labview array.

    nitinkajay wrote:
    I want to know how to store the output of a analog to digital converter into an 2D labview array.
    How exactly are you performing 'Analog to Digital'???
    Grabbing image using camera OR performing data acquisition using DAQ card OR some other way????
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • How to store array of data into a single row of  table ,using any of Stmts

    HI Friends,
    Based on my requirements ,i have retrived a set of data from a XXX.jsp page using a request.getParameter() and stored into single dimenssional array . Now i am paassing that array to JAVA class to store a into some table .
    In JSP page users can add text boxes dynamically based on his intrest then those attributes will store in table .it means table attributes are not conatant , it table attributes may change at any time when user adds any textboxs or any fields on JSP page ....thats my module ..
    Now i wanted to store all array of data into Table in a single row .......thats is my requirements .
    How can we use prepareStatement and Statement to store array of results intoo table row ...on each iteration i wanted to store array of results into table atributes ..It means entire array of results should to into table row at time .....coule any one write sytax ,how we do this...
    could any one suggest me stps that i can impliment ......?....please reply ASAP

    Well ..you code can be works for constant number of attributes in table .oopss here my requirement is table attributes not fixed ,we cant put constant number of place holder(? ) in a statement ,because those are not fixed ,
    Let me explain here :
    i am doing in that way only. As i mentioned you Table attributes are not constant .It may very if users add any fields dynamically on JSP page .If users have option to add any text box on Jsp page ,then that attribute will store in table as a attribute .
    Now i amable fetching the all dyamic form data and stored in a Result Array below ...in this iteration all form result data are from jsp page as suggestion form ,it should stored in table in single row on corrsponding attribtes ......next time when users fills FROM ,then those data i am fetching and storing in a Result Array as below and need to store in corrsponding table attributes in a single row ....
    for(int i=0;i<result.length;i++)
                   System.out.println(result);
                   pst3=connection.prepareStatement("insert into *emprecord* values(?)");
                   if(!result[i].equals(""))
                        System.out.println(result[i]);
                             pst3.setString(1,result[i]);
                             pst3.executeUpdate();
    Thnks in advance ....let me know the the way we can store dynamic form data into dyanamic table ...

  • How to clear the variable value in session store?

    I'll try to build form for search. There are LOV and
    search button on form. When user don't select anything then push
    search button, I'd like the report to show query everything. I
    mean the report will show like condition where id like '%'.
    And I send variable between form to report by using session
    store.
    I select nothing in LOV but value that return by LOV is
    not null. It's in stead of old value of LOV.
    Please tell me.. How to clear the variable value in
    session store? I'd like to set it to null. If you have greater
    way to do like this, please tell me.
    Thank you.

    Please suggest on this..
    Thanks.

  • How to store logical operator in an array in java

    how to store logical operator in an array in java.
    Array should not be String type if i pass an element of that array it should be considered as logical operator

    my exact requirment is like this, i need some logic
    to convert string like this "2 Equals 3 AND 4 greater
    than 7" to condition like this
    2 == 3 && 4 >7 which i can pass to if
    condition.So you want to create an expression parser?
    No need for something as ugly as what you think you need, a simple nested conditional will do it for just the few logical operations.

  • How to store jsp session data of different user in util.hashmap

    how to store jsp session data of different user in java.util.hashmap
    and access the data of all user on the server side
    The same example is given in professional jsp but its not working.
    I can use getIds() of httpsessioncontext but it's depricated

    Hi
    I'm trying to make an example.
    With the following codes you can get the date from the session.
    request.getSession().getAttribute("sessionname")
    To store it in a hashmap you could do it like this ->
    Hashmap hm = new Hashmap();
    hm.put(Object key, request.getSession().getAttribute("sessionname"));
    I hope you understand it if not just write it!
    Cyrill

  • How to store values in session variables for use later

    I am trying to read user input from a form, lookup some values from a database,
    store the combined data into session to retrieve later in the subsequent pages
    in a pageflow application. Could someone guide me as to how exactly to do this?
    The documentation doesn't seem to be of much help.
    Thanks,
    Krishna K

    Krishna,
         If you will be using the data within the course of the same page flow
    or nested page flows then you should store the data in the page flow
    itself. Simply declaring variables in the .jpf will do this. The page
    flow is stored in the session for you and it is deleted when the user
    exits the page flow. This is good because it keeps down session size.
         If you have data that you want to use across page flows then you will
    need to store in the session or globalApp.
         Here is a link to "Using Data Binding in Page Flows" it has an example
    of storing data into the session and it goes into the pros and cons of
    using each data binding scope.
    http://edocs.bea.com/workshop/docs81/doc/en/workshop/guide/netui/guide/conDatabindingXScript.html
    - john
    Krishna Kuchibhotla wrote:
    I am trying to read user input from a form, lookup some values from a database,
    store the combined data into session to retrieve later in the subsequent pages
    in a pageflow application. Could someone guide me as to how exactly to do this?
    The documentation doesn't seem to be of much help.
    Thanks,
    Krishna K

  • Help, how  would I store an array of objects ?

    im doing a java project on creating a music database, i need to store an array of cd objects, each entry in the array will be a single object for a cd.
    The objects are: Artist, Album, No of tracks
    could sum1 point me in d right direction, thanks

    This is the wrong forum. Please ask again in the [new to java forum|http://forum.java.sun.com/forum.jspa?forumID=54] .
    Assuming you want to store them on disk, you can either use a database (java technologies for this is JDBC and JPA ) or write them to a file using the java technologies Serialization or Beans Persistence.

  • How to store something in text file?

    Hello
    I have question and i do not know how to do this.
    can any one explain for me how i can save something in a text file.
    i create calculator,and there is one question i need to do it:((Store the record of the session in a text file. ))
    what i need to write some codes and so on.
    please can u give idea ?

    Alena,
    Here's my static FileUtilz class, which includes a writeFile method, and several other handy methods.
    package krc.io;
    import java.util.Collection;
    import java.util.List;
    import java.util.ArrayList;
    import java.io.File;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.io.InputStream;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import java.util.Arrays;
    public abstract class FileUtilz
        public static final int bfrSize = 4096;
        public static void writeFile(String content, String filename)
        throws IOException
            PrintWriter out = null;
            try {
                out = new PrintWriter(new FileWriter(filename));
                out.write(content);
            } finally {
                //try {if(out!=null)out.close();}catch(Exception ignore){}
                out.close();
        public static String readFile(String filename)
        throws IOException, FileNotFoundException
            FileReader in = null;
            StringBuffer out = new StringBuffer();
            try {
                in = new FileReader(filename);
                char[] cbuf = new char[bfrSize];
                int n = in.read(cbuf, 0, bfrSize);
                while(n > 0) {
                    out.append(cbuf);
                    n = in.read(cbuf, 0, bfrSize);
            } finally {
                //try {if(in!=null)in.close();}catch(Exception ignore){}
                in.close();
            return out.toString();
        public  static String[] readFileIntoArray(String filename)
        throws IOException, FileNotFoundException
            return readFileIntoList(filename).toArray(new String[0]);
        public  static List<String> readFileIntoList(String filename)
        throws IOException, FileNotFoundException
            BufferedReader in = null;
            List<String> out = new ArrayList<String>();
            try {
                in = new BufferedReader(new FileReader(filename));
                String line = null;
                while ( (line = in.readLine()) != null ) {
                    out.add(line);
            } finally {
                try {if(in!=null)in.close();}catch(Exception e){}
            return out;
        public static byte[] readBytes(String filename)
        throws IOException, FileNotFoundException
          //start = System.currentTimeMillis();
          File file = new File(filename);
          byte[] out = new byte[(int)file.length()];
          InputStream in = new FileInputStream(file);
          int size = in.read(out);
          in.close();
          //System.out.println("readBytes("+filename+"="+size") took "+(System.currentTimeMillis()-start));
          return out;
        public static boolean isSameFile(String filenameA, String filenameB)
        throws IOException, FileNotFoundException
          File fileA = new File(filenameA);
          File fileB = new File(filenameB);
          //check for same physical file
          if( fileA.equals(fileB) ) return(true);
          //compare sizes
          if( fileA.length() != fileB.length() ) return(false);
          //compare contents (buffer by buffer)
          boolean same=true;
          InputStream inA = null;
          InputStream inB = null;
          try {
            inA = new FileInputStream(fileA);
            inB = new FileInputStream(fileB);
            byte[] bfrA = new byte[bfrSize];
            byte[] bfrB = new byte[bfrSize];
            int sizeA=0, sizeB=0;
            do {
              sizeA = inA.read(bfrA);
              sizeB = inA.read(bfrB);
              if ( sizeA != sizeB ) {
                same=false;
              } else if ( sizeA == 0 ) {
                //do nothing
              } else if ( !Arrays.equals(bfrA,bfrB) ) {
                same=false;
            } while (same && sizeA != -1);
          } finally {
            if(inA!=null)inA.close();
            if(inB!=null)inB.close();
          return(same);
        public static String basename(String path, boolean cutExtension)
            String fname = (new File(path)).getName();
            if (cutExtension) {
                int i = fname.lastIndexOf(".");
                if (i > 0) {
                    fname = fname.substring(0,i);
            return fname;
        public static String dirname(String path)
            return (new File(path)).getParent();
    }

  • Why we cant store asiciative array in DB

    hi,
    plz provide me vaild reason for below query. its a complex question for me as i tried a lot to find suitable answer in net also but not satisfied.
    1- why we cant store asiciative array in datbase?and we can store netted table in database how?

    >
    why we cant store asiciative array in datbase?and we can store netted table in database how?
    >
    From oracle reference manual.
    >
    Because associative arrays are intended for temporary data rather than storing persistent data, you cannot use them with SQL statements such as INSERT and SELECT INTO. You can make them persistent for the life of a database session by declaring the type in a package and assigning the values in a package body.
    >
    It cannot be made to persist in the db because it's designed in that fashion as mentioned above.
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collections.htm
    Regards
    Raj

Maybe you are looking for

  • Pavilion dv7 - Can I add a second hard drive?

    I have an HP Pavilion dv7 2173cl laptop. I've read that I can add a second internal hard drive. Is that correct? If so, what is the max size that it will take? Any special type that I should buy? Thanks! This question was solved. View Solution.

  • In Generic Delta By selecting 0CALDAY?

    hello all In generic delta,if v select <b>0calday</b> as a delta type,after selecting this delta type v need to select a field for this delta type,should v need to select <b>Time field</b> only(like Creation date,Last date of creation or something li

  • The home button on my ipod touch 4th gen is broken how do i fix it?

    if i cant get it fixed myself how can u get apple to take it and fix it as i still have warrenty

  • ATI Radeon HD 4870 card and HELP on installation

    Hi I really tried to reserach this without being spoon fed but I need some advice I have a "early" MAC pro 2008 and I'd like to upgarde the graphics card to a ATI Radeon HD 4870 (purchased from APPLE) Is it an easy install as far as configuration or

  • Star schema design question

    Hi! I`m trying to build a dw with patient data. I`m mostly interested in the patients` visits table, which will be used for a facts table and the patient table. The patient table contains among others the following data: patient (id, sex, marital_sta