Help needed on accessing an arraylist

Hello
I have declared an arrayList globally as follows:
     ArrayList itemList = new ArrayList();I have then wrote a method to test if a user's session is new, if so set the arrayList into the session using setAttribute. The code then gets the attribute from the session and stores it in the variable listFromSession. This is also set into the session. The code is below:
//ItemList itemList;
          if (ca.isNew()){
               //itemList = new ArrayList();
          ca.setAttribute("itemlist", itemList);
          ArrayList listFromSession = (ArrayList)ca.getAttribute("itemList");
          listFromSession.add(c);
          ca.setAttribute("itemList", listFromSession);I have then tried to retrieve elements from the arrayList. Code is below, but im not sure if im trying to access the arrayList as you would a normal array:
ArrayList listFromSession = (ArrayList)ca.getAttribute("itemList");
                    for (int i = 0; i < listFromSession.length; i++){
                         int amt = listFromSession.getprodQuant(i);
                         int id = listFromSession.getStockID(i);
                         String name = listFromSession.getprodName(i);
                         float price = listFromSession.getprodPrice(i);
                         float totalPrice = amt * price;
                         out.println("<TD>" + id + "</TD>");
                         out.println("<TD>" + name + "</TD>");
                         out.println("<TD>" + amt + "</TD>");
                         out.println("<TD>" + price + "</TD>");
                         out.println("<TD>" + totalprice + "</TD>");
                    }For example, i did originally have int amt = listFromSession(i).getprodQaunt; and so forth but that threw the same error: cannot find symbol getProdQuant even when I put code it in the example above.
Basically the compiler cannot find the get methods nor the variable length(), ive tried size() but it dosn't like that either
Can anyone help?
Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Can anyone understand as to why my arraylist cannot be accesssed or return the elements?
Is it because the initialization is outside of the method that is accessing the list?
package cart;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Enumeration;
import cart.CartItem;
public class CartSession extends HttpServlet
     private HttpSession ca = null;
     private int numProducts = 0;
     ArrayList itemList = new ArrayList();
     ArrayList listFromSession = new ArrayList();
       public void doPost(HttpServletRequest request,
                               HttpServletResponse response)
            throws ServletException, IOException
         response.setContentType("text/html");
          PrintWriter out = response.getWriter();
          int currentProduct = Integer.parseInt(request.getParameter("stock"));
          String currentName = request.getParameter("name");
          float currentPrice = Float.parseFloat(request.getParameter("price"));
          String am = request.getParameter("Amount");
          if (am == null) am = "1";
          int currentAmount = Integer.parseInt(am);
          cart.CartItem c = new cart.CartItem(currentProduct, currentName, currentPrice, currentAmount);
          ca = request.getSession();
          //ItemList itemList;
          if (ca.isNew()){
               //itemList = new ArrayList();
          ca.setAttribute("itemlist", itemList);
          ArrayList listFromSession = (ArrayList)ca.getAttribute("itemList");
          listFromSession.add(c);
          ca.setAttribute("itemList", listFromSession);
          ca.setAttribute("currentProd", c);
          sendPage(response);
     private void sendPage(HttpServletResponse reply) throws IOException
                    reply.setContentType("text/HTML");
                    PrintWriter out = reply.getWriter();
                    out.println("<HTML>");
                    out.println("<HEAD>");
                    out.println("<TITLE></TITLE>");
                    out.println("<HEAD>");
                    out.println("<BODY><H1>Your Shopping Cart</H1>");
                    out.println("<CENTER>");
                    out.println("<BR><BR><BR>");
                    //cart.removeAttribute("currentProd");
                         out.println("<TABLE BGCOLOR=Aqua BORDER=2>");
                         out.println("<TR>");
                         out.println("<TH>Stock ID</TH>");
                         out.println("<TH>Product</TH>");
                         out.println("<TH>Quantity</TH>");
                         out.println("<TH>Unit price</TH>");
                         out.println("<TH>Total price</TH>");
                         out.println("</TR>");
                    ArrayList listFromSession = (ArrayList)ca.getAttribute("itemList");
                    for (int i = 0; i < listFromSession.length; i++){
                         int amt = listFromSession.getprodQuant(i);
                         int id = listFromSession.getStockID(i);
                         String name = listFromSession.getprodName(i);
                         float price = listFromSession.getprodPrice(i);
                         float totalPrice = amt * price;
                         out.println("<TD>" + id + "</TD>");
                         out.println("<TD>" + name + "</TD>");
                         out.println("<TD>" + amt + "</TD>");
                         out.println("<TD>" + price + "</TD>");
                         out.println("<TD>" + totalprice + "</TD>");
                         //See if user wants more items
                         out.println("<FORM METHOD=POST ACTION='paymentform.html'>");
                         out.println("Would you like to<BR>");
                         out.println("<INPUT TYPE=SUBMIT VALUE=\" Add more items \">");
                         out.println("<FORM METHOD=POST ACTION='paymentform.html' \">");
                         out.println("<INPUT TYPE=SUBMIT VALUE=\" Check Out \">");
                    out.println("</TABLE>");
                    out.println("</FORM>");
                    out.println("</CENTER>");
                    out.println("</BODY>");
                    out.println("</HTML>");
                    out.flush();
{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Help needed to access internet while roaming

    Hi, I m new to this community and do not know properly how to get support. I have I pad mini with retina display, WiFi & Cellular, 32 GB, OS: iOS 7.1.2. To use internet I have taken Vodafone SIM (UP, West, India) which is a handmade nano SIM. I am able to use internet facility when present in home circle. However, when I visit to other states I can not access internet (even after the setting change as a roaming). Whenever I open the browser, message comes on screen "Could not activate cellular data network" or "You are not subscribed to a cellular network service". In this connection I contacted ISP (Vodafone), but they say there is no problem with ISP and suggest me to contact Apple. I made contact with apple too. They made all the heat and trial with the setting but the result was the same. Finally they say this problem could be because of hand cut nano SIM and suggested me to get factory cut nano SIM. I am still having hand cut SIM. I request all of you to help me in this regard so that I could use internet while traveling.
    Thank you
    Arun Verma

    Get a factory cut nano sim as Vodaphone suggested. The handout sim seems
    to have a problem. Is there some reason you don't want to follow the suggestion
    you have been given?

  • Urgent Help needed : Connecting Access 2000 with forms 6i

    Dear friends,
    I am really struggling to solve this connection issue. I am working with forms 6i, oracle 8i, in Windows XP pro environment. Developing programs using oracle 8i tables is ok, but there are tables in Access 2000, which I have to add the program that I am developing. The things I have done are
    - I have already tables in MS Access databse.
    - I Installed ODBC for microsoft and for Oracle as well(which . I added the MS Access Database there and I can perfom SQL from Oracle ODBC.
    - I also installed OCA for developer from the CD.
    From this point I followed the instructions in Developer Help menu and I was not able to connect and still trying, I will appreciate if anyone provide me sometips. Thanks in advance
    Best Regards

    Hi,
    I know the bad solution. But anyway, I'll tell you in any kind of help. I also had an AccessControlException when I started a RMI client program using JFileChooser. I rewrote policy files again and agin, but in vain. The last and ultimate method I did was remove the RMISecurityManager. This is obviously dangerous in the Internet, but if you use your application in the intranet or in some kind of safe environment. There would be no problem.
    Hope this could be any kind of your help.

  • Help needed to access Oracle from Applet.

    Please help. I have spent days reading info on the web and I simply cannot access to Oracle from an applet to work. Oracle is on a different IP than the Web Server. For my testing I am running the html directly from my local file system.
    Here are the steps I have taken:
    1. Create a key: "%JAVA_HOME%/bin/keytool" -genkey -alias MyAlias -keypass MyKPass -keystore C:\Keys.bin -storepass MySPass
    2. Sign my jar: "%JAVA_HOME%/bin/jarsigner" -keystore C:\Keys.bin -storepass MySPass -keypass MyKPass -signedjar myjar-signed.jar myjar.jar MyAlias
    3. Sign Oracle's Jar: "%JAVA_HOME%/bin/jarsigner" -keystore C:\Keys.bin -storepass MySPass -keypass MyKPass -signedjar ojdbc14-signed.jar ojdbc14.jar MyAlias
    4. Applet Tag (at this time I have the two jars in the same folder as the HTML and JS files):
        <applet id="MyApp"
      codebase=""
      archive="myjar-signed.jar,ojdbc14-signed.jar"
      code="com/company/applets/Test.class"
      mayscript
      width="50" height="50">
        </applet>5. Javascript:
      document.observe("dom:loaded", function() {
      alert("Applet: " + $('MyApp').getVersion());
      $('MyApp').getConnection(url, user, pswd);
      alert("Applet: " + $('MyApp').getVersion() + "Got Connection.");
      $('MyApp').testConnection();
      alert("Applet: " + $('MyApp').getVersion() + "Connection Tested.");
    });Execution:
    1. The applet loads, The browser asks if I want to trust it, I say yes.
    2. The '$('MyApp').getVersion()' works.
    3. The '$('MyApp').getConnection(url, user, pswd);' fails. Java Code:
      public void getConnection(String url, String user, String pswd)
          throws Exception {
        try {
          System.out.println("Driver...");
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          System.out.println("Connection...");
          _conn = DriverManager.getConnection(url, user, pswd);
          ...The driver registers, but the getConnection fails with a security error.
    After much reading, I used policytool to update the policy file. It added:
    keystore "file:/C:/Keys.bin", "jks";
    grant signedBy "MyAlias" {
      permission java.security.AllPermission;
    };This did not make any difference. Both IE and FF get the same error.
    The JRE being used is 1.6.0_14.
    Any help solving this would be MUCH appreciated.
    Thanks.

    I have simplified the problem, and now it has nothing to do with Oracle. It is a certificate/signing problem.
    Here are the steps I took to set the test up:
    Certificate:
    "%JAVA_HOME%/bin/keytool" -genkey -storepass MyStorePswd -keyalg RSA -alias MyRsa -dname "CN=Company.com, OU=IT, O=Company Inc, L=Atlanta, ST=Georgia, C=US, DC=mailexpress, DC=com" -validity 999
    "%JAVA_HOME%/bin/keytool" -selfcert -storepass MyStorePswd -alias MyRsa -validity 999
    "%JAVA_HOME%/bin/keytool" -exportcert -storepass MyStorePswd -alias MyRsa -rfc -file MyRsa.cer
    "%JAVA_HOME%/bin/keytool" -importcert -keystore "C:\Program Files\Java\jre6\lib\security\cacerts." -storepass changeit -alias MyRsa -file MyRsa.cer
    Jar Signing:
    "%JAVA_HOME%/bin/jarsigner" -storepass MyStorePswd -keypass MyStorePswd -signedjar Text-Project-signed.jar Text-Project.jar MyRsa
    "%JAVA_HOME%/bin/jarsigner" -verify Text-Project-signed.jar
    Result: jar verified.
    HTML:
        <applet id="MyApp"
                codebase="file:/c:/projects/Text-Project/js/Memory"
                archive="Text-Project.jar"           <== unsigned test  OR
                archive="Text-Project-signed.jar"    <== signed   test
                code="com/company/applets/MemTest.class"
                mayscript
                width="50" height="50">
        </applet>
    JavaScript:
    document.observe("dom:loaded", function() {
      alert("Applet: " + $('MyApp').checkSecurity());
    Function in the Applet:
      public String checkSecurity() {
        System.out.println("Security Check...");
        try {
          AccessController.checkPermission(new FilePermission("MemTest.js", "read"));
          AccessController.checkPermission(new FilePermission("MemTest.js", "write"));
          AccessController.checkPermission(new java.net.SocketPermission("192.168.1.121", "resolve"));
        } catch (Exception e) {
          e.printStackTrace();
          return e.getMessage();
        return "Security Checked OK";
      }Results (Internet Explorer):
    1. Unsigned JAR, No policy:
    Result = java.security.AccessControlException: access denied (java.io.FilePermission MemTest.js read)
    (as expected)
    2. Unsigned JAR, Policy = permission java.security.AllPermission:
    Result = Security Checked OK
    (as expected)
    3. Signed JAR, No Policy: Popup states: signature verified; do you want to run the application.
    Result = java.security.AccessControlException: access denied (java.io.FilePermission MemTest.js read)
    (not expected)
    Something is wrong with the certificate or signing process. Any ideas ?
    Thanks.
    Edited by: javadude.101 on Jul 29, 2009 12:29 PM

  • Help needed to access a file from and email link.

    I received an email with a link to an Adobe document. When I attempt to open the link I receive a message " You do not have accewss to the file" How do I gain access?

    Then it is the case I mentioned, the author sent the URL from the address bar viewing the form in Edit mode rather than copying the Fillable Form link. 
    You'll need to respond to the form author and ask them to send out the correct link/URL to the fillable form (which does not ask for any login).  They can go to the "Distribute" tab and on the "Web Form" sub-tab click "Copy Link", if the form is "Closed" it will ask if they want to "Open" the form, the form needs to be in the "Open" state to collect responses so say "Yes".  This will copy the link to their clipboard and they can then send that link/URL out.
    Also, if they close the form (by clicking the X in the upper right corner) and are looking at the "My Forms" tab in FormsCentral, with the form selected there is a "Link" button in the toolbar along the top which copies the form URL to send out.
    Here are a few documents that include information on how to distribute forms: https://www.acrobat.com/formscentral/en/quickstart/distribute-web-form.html
    http://forums.adobe.com/docs/DOC-1413
    http://helpx.adobe.com/acrobat-com/formscentral/topics.html
    Thanks,
    Josh

  • Help needed in accessing the url from which a swf file has been loaded

    Hi All,
    Can anyone help me out in finding the url of the swf file
    from which it has been loaded? The purpose of the url is, I am
    loading some flv files using relative path. I just want to achieve
    the same by appending the relative path to the parent swf url from
    where the parent was loaded.
    I am a newbie to AS3, So please don t mind if this is a silly
    question.
    Can anyone help me on this.
    Thanks in advance,
    Prabakaran Srinivasan.

    Hi,
    Thanks for the reply. I think the option you gave is only
    applicable when the AS3 class comes in the DisplayObject hierarchy.
    I want this information in an AS3 class which does not extend any
    of the Sprite or its super class hierarchy. Can you let me know the
    possibility of fetching the value from such a class which i
    specified???
    Thanks,
    Prabakaran Srinivasan.

  • Help needed to access site using safari

    I am new to Mac and there is this one perticular site that I am un able to log on to.
    I am using a macbook air with Safari 6.0.5 (8536.30.1)
    I have tried changing the user agent on safari but this did not help.
    After I type in my username and password this appears:
    <%@ page buffer=500 %>
    The exact problem occured before while using internet explorer and this was solved by using the compatibility view on internet explorer.
    I think that this suggest that the site was built on an early version of internet explorer and I dont have the user agent strring fot that version.
    Or it can be a compatibility issue that a user agent change cannot fix.
    I also recorded these properties while on the site using internet explorer:
    Protocol               HyperText Transfer Protocol with Privacy
    Type                      HTML Document
    Connection         TLS 1.0, AES with 128 bit encryption (High); RSA with 1024 bit exchange
    Zone                      Internet | Protected Mode: On
    The option of installing windows on my Mac is a last resort, another solution will be most welcome.
    Thanks
    Seunarine

    Try another browser - Firefox, say - or Opera.

  • Help needed. Access Driver Error

    This is basically my code:
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String sourceURL = "jdbc:odbc:my_Library";
    Connection databaseConnection = DriverManager.getConnection(sourceURL);
         if(authorNames.getInt("Available") == 0)
              {     // Do this when book is currently on loan          
                   Statement SQLstatement = databaseConnection.createStatement();
                   String changeLastName = "UPDATE tblAvailable_Items SET Reserved_by = ? WHERE Item_ID = ?";
                   PreparedStatement updateLastName = databaseConnection.prepareStatement(changeLastName);
                   updateLastName.setString(1,"Nigel");
                   updateLastName.setLong(2,9);
                   updateLastName.executeUpdate();
    When I run this in my browser I get the following error:
    "java.sql.SQLException: [Microsoft][ODBC Microsoft Access 97 Driver]Driver not capable "
    Any ideas why this won't work?

    Hi wrote for luck!
    I am starting to learn how to manipulate access database using JDBC.
    I am reading a book but it uses Informix as its database. Can you send me a sample program using an Access 2000 database in JDBC? My email is [email protected]
    Thanks in advance!
    Cheers,
    Moses

  • My ipad mini does not restart when i press and hold the home and power buttons for a minute or more. what do i do? i really need to access some information on it. please help.

    my ipad mini does not restart when i press and hold the home and power buttons for a minute or more. what do i do? i really need to access some information on it. please help.

    You need to connect to iTunes and restore.
    iOS: Not responding or does not turn on
    You may need to put the device into recovery mode, this is covered in the link on this page.
    Did you back up the device?

  • I have just upgraded to the new OS X V. 10.10.3 but cannot access my iCloud Drive documents using the resident Pages and Numbers software on my MacBook Pro. Help needed.

    I have just upgraded to the new OS X V. 10.10.3 but cannot access my iCloud Drive documents using the resident Pages and Numbers software on my MacBook Pro. Help is needed to access those documents using the resident software on my MacBook Pro rather than the Beta software on iCloud.com.

    I have iCloud Drive set on the Finder sidebar and use that to open the Numbers Spreadsheet on iCloud.
    OSX 10.10.3
    Best.

  • When I try to open pages 09 all i get is spinning beach ball.  I have a lot of quotes i need to access but cannot. HELP!!!!!!

    when I try to open pages 09 all i get is spinning beach ball.  I have a lot of quotes i need to access but cannot. HELP!!!!!!
    It has been fine up until this morning.  Its stressing me out now as i may haveto retype loads. 

    Hi fruhulda, I am currently running 10.9.1
    I have tried both ways.  Generally I save a current quote to desktop and so open the programme by clicking on the quote thumbnail. 
    Thankys for your reply by the way.

  • HT1212 Right, home button broken, locked out. Help... i need to access the recovery mode

    Right, home button broken, locked out. Help... i need to access the recovery mode

    Place the iPod in recovery mode using one of these programs:
    For PC
    RecBoot: Easy Way to Put iPhone into Recovery Mode
    If necessary:
    Download QTMLClient.dll & iTunesMobileDevice.dll for RecBoot
    and                         
    RecBoot tip
    For MAC or PC       
    The Firmware Umbrella - TinyUmbrella

  • I need help trying to access my spotlight messages.

    I need help trying to access my spotlight messages.  I type in the persons name and only one text comes up but when I type in words in the text other ones come up.  So what I need to do is get all those text messages if its possible.

    I know the texts are there, but like I said it depends on the spotlight search but I want them all in one.

  • I am developing a flex web application which needs to access Other domain ,is there any other way other than cross domain policy available ? please help

    i am developing a flex web application which needs to access Other domain (Payment Gateway API),is there any other way other than cross domain policy available ? please help.
    we donot have access other domain thats why we want other solution..

    All the paths to CFCs are the same in my live production site.  Can you be more specific as to what you mean by "RemoteClass aliases in your AS Classes and CFCs (if any) are correct."?  How will the app know that the CFC is on http://myLiveSite.com instead of http://myDevSite.com?  The only line of code that I have noticed that points to a URL is the endpoint in a file called _Super_XXX.as.  And at the top of that file it says that the file is not meant for editting.
    To clarify...I see your app/code all exists on a server access via a web browser so I can understand that everything still works when deployed.  Mine is a mobile app so when I am developing and testing on my local computer the URL points to my local development machine.  However when I deploy it to a mobile device like a tablet and run the app, it needs to be able to access a cfc on a remote server via a different URL ie. my http://myLiveSite.com/myCFC.cfc instead of http://localhost/myCFC.cfc
    Thanks for your help!  I will now take a look at your thread.
    Message was edited by: ace0215

  • I updated Lion on OSX to Maverick OSX10.9.1 and now don't have Universal Access in Preferences only Access, Why? I need Universal Access to install Dragon Dictate, can you help?

    I updated Lion on OSX to Maverick OSX10.9.1 and now don't have Universal Access in Preferences only Access, Why? I need Universal Access to install Dragon Dictate, can you help?

    It was replaced by Accessibility in Mac OS X 10.8.
    (95895)

Maybe you are looking for

  • How do I create a pdf in Indesign with 40 file hyperlinks so it can be used on different computers?

    I am creating a document in Indesign CS4 that is to be exported as a pdf. Within this one page document, there are approximately 40 listed products, one after the other and each product has been set up to hyperlink to a specific pdf in the same direc

  • How to remove excess whitespace below my footer in muse

    If you go to Admiral Computer Systems - IT Services in London And Kent on every page of the website below the footer is a large chunk of excess whitespace that i want to get rid of its there regardless of whether sticky footer is checked or not. the

  • Can someone explain the logic...?

    I have two questions... 1.  How do I get back to the "factory settings" for the server environment?  I was playing around with settings and somehow now the default website on the server is looking at /var/empty instead of /Library/Server/Web/Data/Sit

  • Problem with transaction ME21N

    Hi Experts,           Please help me out my requirement,i m not getting what i will do.            My requirement is Modify the Standard transaction ME21N. Means i need to delete some  tabs in that transaction, which my client is not use and also add

  • Status Errors In RBDMANI2

    I am currently experiencing a problem in using program RBDMANI2 to reprocess some failed IDOCs whereby the status message is being appended to the wrong IDOC.  For example, IDOC no 1234 fails, as does IDOC 1235.  Periodically, RBDMANI2 is run in batc