How to access parameters from an object stored in a shopping-cart vector?

Hello;
I am writing some code that will be part of a website that will have the
ability to allow customers to place items into a shopping cart and then
purchase them.
The way that the shopping cart works is that a products page is displayed on the website that has 'add' buttons on it next to each product on the page.
When the customer clicks the 'add' button next to a particular product to purchase it, the code performs a query of a products database table for the numeric product id linked to the 'add' button they clicked.
When the product id is found, the query then loads the
product information for it from the DB table columns into the shopping cart
Vector as an object in the form of a result set string. This object contains
the parameters that define the product, i.e. product_id, product_quantity,
date_ordered, ship_status and so on.
In the code, when the customer is done shopping and clicks on a button
labelled 'place order', I want the code to access the shopping cart Vector
and extract each item object from the cart. I then want the code to be able
to get from each item object, the parameters that make up each item as
described above and take the values stored in each of the parameters and
store them in variables. Finally I want to take those variables and write
them to an orders DB table in the proper columns via a query.
I have tried researching information on Vectors to see if I could find out a way to do this but the little information that I located did not give me a clear idea
of how to go about writing the code, it only seemed to suggest a vague,
rough idea as to how it might be done. I am relatively new to Java
programming and so don't have any experience working with Vectors.
I have enclosed the code below that shows how the items are being stored in the shopping cart Vector. Can anybody tell me how I could go about writing the code that will extract the items from the shopping cart as described above in a servlet? Any assistance you can give me will be greatly appreciated.
Thank you!
String productID = request.getParameter("productID");
String qty = request.getParameter("qty");
Vector cartlist = new Vector();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:odbc:website", "", "");
java.sql.Statement st = conn.createStatement();
String query = "SELECT productID, productName, productCategory,
productPrice from Products WHERE productID ='" + productID + "'";
java.sql.ResultSet rs = st.executeQuery(query);
while(rs.next()){
cartlist.addElement(rs.getString("productID") + " " +
rs.getString("productName") + " " +
rs.getString("productCategory") + " " +
rs.getString("productPrice") + " " + qty);
} catch(SQLException sqlex){
} catch(Exception e){
}

//Try Changing your code this way.
String productID = request.getParameter("productID");
String qty = request.getParameter("qty");
Vector cartlist = new Vector();
try
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:odbc:website", "", "");
     java.sql.Statement st = conn.createStatement();
     String query = "SELECT productID, productName, productCategory, productPrice from Products WHERE productID ='" + productID + "'";
     java.sql.ResultSet rs = st.executeQuery(query);
     while(rs.next())
          String productID = rs.getString("productID");
          String productName = rs.getString("productName");
          String productCategory = rs.getString("productCategory");
          String productPrice = rs.getString("productPrice");
          String productID = rs.getString("productID");
          cartlist.addElement(new AddCardElement(productID, productName, productCategory, productPrice, productID, qty));
          //class AddCardElement should be there in your application
catch(SQLException sqlex)
catch(Exception e)
//you have to add a new class AddCardElement like this
class AddCardElement
    public String m_productID;
     public String m_productName;
     public String m_productCategory;
     public String m_productPrice;
     public String m_productID;
    public GenerateLocationData(String productID, String productName, String productCategory, String productPrice, String productID, String qty)
        m_productID = productID;
          m_productName = productName;
          m_productCategory = productCategory;
          m_productPrice = productPrice;
          m_productID = productID;
}//-Achyuth B

Similar Messages

  • How to read parameters from request object

    We want to read parameters from GET request
    but whenever we are calling GET_URI_PARAMETER from the REQUEST we don't see any results
    url is like
    http://coevi116.wdf.sap.corp:8000/sap(bD1lbiZjPTEwMA==)/bc/bsp/sap/z_test_json/jsontest.htm?PARAM=ABC
    But reading PARAM is not givng value of ABC
    onCreate and onRequest wherever we put the code it is not reading the value
    Can anyone please help and share some expert opinion

    in jsontest.htm page create a page attribute named "PARAM" with auto check box checked and check in oninitialization, this will carry the value passed to param from url.

  • From my iPad I can print wirelessly in my office, but how do I print remotely via the web through my HP ePrint printer.  It is set up with an email address but i don't know how to access it from my iPad.

    I can print wirelessly in my office from my iPad, but how do I print remotely via the web to my HP ePrint printer.  The printer is set up with an email access address but I don't know how to access it from my iPad.

    Read through this for some information on how to do this:
    http://www8.hp.com/us/en/support-topics/mobile-printing/how-to-print-mobile-devi ces-ipad-iphone.html

  • How to access symbol from different stage

    Hi everyone,
    I'm really new at Edge, so I still have a lot to learn and I need your help with something..
    I want to know how to access a symbol from another stage, here's what I've and what I want to do..
    I've the main index page with symbol named "content", in content I load other composition (page). called "page2".
    all I want to do is when I click a symbol "XX" inside "page2". The "content" symbol loads other composition called "page3".
    I don't know how to access "Content" from "page2", so I could load "page3" ..  that's it
    I feel like it's simple, but I just couldn't know how to do it, I',m sorry for bothering you for such a question, but I've searched a lot and I got nothing.
    Thanks
    I thought I could use something like this
    var comp = Edge.getComposition("EDGE-638329");  
    var stage = comp.getStage(); 
    var symp= comp.stage.getSymbol("content");
    EC.loadComposition("assets/units/stage1/s1_3/s1_3.html",symp);
    but it's still not working, could someone please tell me what I'm doing wrong?

    I have multiple compositions, where I need to go from one to another.
    I use click scripts in an element to do this, using identical pages with different animations on each page.:
    Click script:
    AdobeEdge.goLoc(url); //url is the URL of an identical new html page with a different animation
    Then I have a custom .js page that I use that has the function:
    AdobeEdge.goLoc = function(url) {
    location=url;
    Peter Small

  • How to filter Choose from list object rows?

    Hi everyone,
    I'd like to show Choose from list window using SBO 2005 PL07, Actually I want to show the Active Account of G/L Account, I set the CFL object to one column as following:
    oCFLCreationParams.ObjectType = SAPbouiCOM.BoLinkedObject.lf_GLAccounts
    oCFLCreationParams.UniqueID = "CFL"
    oCFL = oCFLs.Add(oCFLCreationParams)
    Who knows how to set Choose From list object only show Active Account and do not show Title Account.
    Thanks for your help!
    Kathy

    Hi kathy
    I have not tried it on the gl accounts. But basicaly you need to add conditions to filter it. The following is an example that you would of used for business partners but only customers.
      Dim oCFLs As SAPbouiCOM.ChooseFromListCollection
                Dim oCons As SAPbouiCOM.Conditions
                Dim oCon As SAPbouiCOM.Condition
                oCFLs = oForm.ChooseFromLists
                Dim oCFL As SAPbouiCOM.ChooseFromList
                Dim oCFLCreationParams As SAPbouiCOM.ChooseFromListCreationParams
                oCFLCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)
                ' Adding 2 CFL, one for the button and one for the edit text.
                oCFLCreationParams.MultiSelection = False
                oCFLCreationParams.ObjectType = "2"
                oCFLCreationParams.UniqueID = "CFL1"
                oCFL = oCFLs.Add(oCFLCreationParams)
                ' Adding Conditions to CFL1
                oCons = oCFL.GetConditions()
                oCon = oCons.Add()
                oCon.Alias = "CardType"
                oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
                oCon.CondVal = "C"
                oCFL.SetConditions(oCons)
                oCFLCreationParams.UniqueID = "CFL2"
                oCFL = oCFLs.Add(oCFLCreationParams)
    The above also compensates for the tab.
    Hope it helps

  • I created a folder from my camera roll and shared with my icloud acct, can't figure out how to access it from my computer?

    I created a folder from my camera roll and shared with my icloud acct, can't figure out how to access it from my computer? I log onto icloud and can't find anywhere where "shared" photos are..

    You need Mountain Lion (10.8.2 or higher) and iPhoto '11 (9.4 or higher) or Aperture 3.4 to get shared photo streams on Mac.
    Another option to transfer them is to either import them to iPhoto using your usb cable, as explained here:http://support.apple.com/kb/HT4083, or to us an app like PhotoSync to transfer them to your Mac over your wifi.  (PhotoSync will also transfer albums, not just photos from the camera roll.)

  • How does a workflow get triggered when we create a Shopping cart

    Hi all,
    In SRm how does a workflow gets triggered when we create a Shopping cart...what i mean is that in r/3 we use changedocument object or function modules etc..likewise in srm how the wf gets triggere...can anyone help me.
    Thanks&Regards,
    Hari

    Hi martin,
    yes i accept that in SRM also workflows are all started by event...what i mean is in R/3 we go for Change document object(swec) or some other method for event creation...like that in SRM what is there?Just whenwe create a Shopping cart How the workflow is trigerred...suppose if it is trigerred using fm swe_event_create where they might have called the function module.
    Thanks&Regards,
    Hari

  • How to create new starting conditions for a workflow of shopping cart

    Hi all,
    How to create new starting conditions for a workflow of shopping cart
    SATYA

    Excecute SWB_COND
    Creating New:
    Click on Create button. If you cannot see that it could be a authorization issue
    then Business Object:  BUS2121
    Double Click the event linkage for one step workflow
    Define the expressions, Check Consistency and click on Traansfer
    Start Condition is created. If it is not Active click on the Red Button to make it Active
    Editing Already existing:
    Click on Edit Button If you cannot see that it could be a authorization issue
    then select Business Object:  BUS2121
    Click on the condition part (White area) of the start condtion needing editing
    Change the expressions, Check Consistency) and click on Traansfer.If it is not Active click on the Red Button to make it Active

  • Price from MDM is not transferred to shopping cart in EBP

    Hi all,
    we are implementing MDM 2.0/SP2 for SRM. Actually the catalog content is fully available, the only problem is that I don't get the price from catalog into shopping cart via OCI. When I browse through catalog coming from EBP every price in MDM-shopping cart (WEB UI) is displayed correctly. When I transfer the articles from MDM-shopping cart to EBP every field is transferred correctly except price. When I test with Fiddler I also don't see price coming in, and I also don't see any system message in system log SLG1 of EBP.
    These are my settings:
    Price in MDM data manger like:
         Price Information: 1| |AVL Graz|12.14| Euro
    OCI:
    NEW_ITEM-PRICE            Price Information -Amount (not transferred)
    NEW_ITEM-CURRENCY    Price Information - Currency (transferred correctly)
    NEW_ITEM-PRICEUNIT     Price Information - Price Base Quantity  (transferred correctly)
    Did you guys have a similar problem before?
    Best Regards Thomas

    Hey Thomas,
    As specified by u can see items with their prices in the Data Manager as well as in the Shopping cart but not on EBP side.
    These were the settings u had specified:
    OCI Mappings:
    NEW_ITEM-PRICE Price Information -Amount (not transferred)
    NEW_ITEM-CURRENCY Price Information - Currency (transferred correctly)
    NEW_ITEM-PRICEUNIT Price Information - Price Base Quantity (transferred correctly)
    Please do check wether the items which u r purchasing is having all the values populated.
    Bcoz as given u havnt specified Orderunit field and Minimum Quantity UOM.
    As per my understanding to purchase any item, and take it onto the EBP side with its price the Orderunit field must be populated with Unit of Measure.
    After inserting values in Order unit and Minimum Quantity UOM then go and check wether its price is taken from the Shopping cart to the EBP.
    Please check it will work
    Do let me know
    Hope dis helps u
    Regards Tejas...............

  • Accessing parameters from request header in init()

    Hello
    How can I access parameters passed on the client request header like
    http://localhost:8080/servlet/DBServlet?database=mydatabase
    from the servlet initialization method ini()
    The getInitParameter() only returns parameters defined in the web.xml file (if is this correct).
    I would like to use the getParameter() from the request class, how can I do this within init()
    Thanks

    Greetings,
    Hello
    How can I access parameters passed on the client
    request header like
    http://localhost:8080/servlet/DBServlet?database=mydat
    base
    from the servlet initialization method ini()You can not. As you pointed out, the init() method is for servlet initialization - it is called by the container to allow the servlet to prepare to receive requests, which are then passed to the service() method.
    The getInitParameter() only returns parameters defined
    in the web.xml file (if is this correct). That is correct - parameters can be defined in the deployment descriptor in either the <servlet> level (passed to the servlet in ServletConfig), or the <webapp> level (passed to the entire webapp in ServletContext).
    I would like to use the getParameter() from the
    request class, how can I do this within init()Again, you can not - there simply is not any client communication during initialization.
    ThanksRegards,
    Tony "Vee Schade" Cook

  • How to access variables from other class

        public boolean inIn(Person p)
            if  (name == p.name && natInsceNo == p.natInsceNo && dateOfBirth == p.dateOfBirth)
                 return true;
            else
                 return false;
        }//returns true if Person with same name/natInsceNo/dateOfBirth as phello,
    here am trying to compare the existing object with another object.
    could you please tell me how to access the variables of other class because i meet this error?
    name cannot be resolved!
    thank you!

    public class Person
        protected String name; 
        protected char gender;      //protected attributes are visible in the subclass
        protected int dateOfBirth;
        protected String address;
        protected String natInsceNo;
        protected String phoneNo;
        protected static int counter;//class variable
    //Constractor Starts, (returns a new object, may set an object's initial state)
    public Person(String nme,String addr, char sex, int howOld, String ins,String phone)
        dateOfBirth = howOld;
        gender = sex;
        name = nme;
        address = addr;
        natInsceNo = ins;
        phoneNo = phone;
        counter++;
    public class Store
        //Declaration of variables
        private Person[] list;
        private int count;
        private int maxSize;
    //constructor starts
        public Store(int max)
             list = new Person[max];//size array with parameters
             maxSize = max;
             count = 0;
        }//end of store
    //constructor ends
    //accessor starts  
        public boolean inIn(Person p)
           return (name == p.name && address == p.address && natInsceNo == p.natInsceNo);
        }//returns true if Person with same name/natInsceNo/dateOfBirth as phope it helps now!

  • Accessing details from multiline object attribute..

    Hi Workflowers, help sought..
    Can anyone show me how I can access the <u>value</u> attributes of a <u>multiline object reference</u> attribute.
    For example, I want to create a new multiline attribute in the <i>SalesOrder</i> object (ZBUS2032) called <b>LineQuantities</b>.  ZBUS2032 has a multiline <u>object reference</u> attribute called <i>Items</i>. I want to place the QUANTITY attributes of all of the <i>Items</i> of the SalesOrder into my new <b>LineQuantities</b> attribute.  What is the syntax to retrieve all the QUANTITY attributes of the <i>Items</i> to my new multiline attribute of the SalesOrder?
    Can I use something like
    SWC_GET_TABLE_PROPERTY self  'Items'  <b>it_quantity</b>
    to retrieve a list of the <i>Items</i> quantity attributes? In that case, <b>it_quantity</b> would need to be defined as a table of object references, and I would still need to get the quantity attribute from each object somehow. There is probably straightforward way to do this, if someone can enlighten me.
    Not sure how to do it, any pointers much appreciated.

    Hi Tony,
    Please confirm, First of all did you copy as Subtype of BUS2032. Don't copy directly.
    define virtual attribute for Quantity, then you can use multiline container element.
    Check this Link for more details:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c5/e4acd5453d11d189430000e829fbbd/frameset.htm
    Thanks and Regards,
    Prabhakar Dharmala

  • How to transfer parameters from one ivew to another-both are in diff. page

    Hi All,
    My requirment is pass the parametrs from one ivew to another ivew(both are different PCD paths). now i am able to see the value in second ivew using java script .Here my problem is come.
    How to transfer varibles from one i vew to another ---Afetr seeing so many forums in SDN.I came to know that EPCM is Best. Using EPCM i am able to transfer the varible and able see the vlues in javascripts(Using alert command).
    From java script how to transfer varible to bean-----afetr seeing forums i came to know that using HTTPSession we can pass parameters to bean. but i am unable to code where i need to call httpsession api methods,it mean that i need to code under  java script , JSp and controller page.
    it is very urgent for me,
    thanqs in advance

    Hi,
    Goto LT01 transaction with Movment type = 999 and stock category = Required stock category. Create a PCN and process the remaining process so as to change the stock type.
    Regards,
    Dilli Babu R

  • How to load data from info object to ODS

    Hello BW Gurus,
    Is their any way to load data from info object to ODS and I am unable to fine the Info source for that particulate info object master data.
    For ex: we have 0PROFITCENTER as info object which is getting loaded everyday. We want same data in ODS too but I don't find any info source related to this info object to create update ruled.
    Please advise me how to proceed with this,
    Thanks,
    Swathi.

    hi Swathi,
    as mentioned, if you just need the master data text or attribute update, then it's sufficient to load 0PROFITCENTER master data. (don't forget to 'apply hierarchy/attribute change' - rsa1->tools)
    if you are going to update attribute in ods with attribute from 0PROFITCENTER, you can choose look up master data attribute method in update rules.
    if the requirement is really need 0PROFITCENTER to assign to update rules, then first you have to 'generate export datasource' for infoobject 0PROFITCENTER, right click the infoobject and 'generate export datasource', then do 'replicate datasource' from bw myself, after that it will available. to display it you may go to rsa1->infosource, and menu settings->display generated objects.
    hope this helps.

  • OWSM Policy - how to access subject from within protected service

    I am setting up a new instance of SOA Suite 11g for integration purposes at my organization. I am planning to use predefined WSM policies to protect the services (see http://download.oracle.com/docs/cd/E12839_01/web.1111/b32511/policies.htm).
    Most communication is server-to-server (e.g. HR sending data to CRM), so it would make sense to use something like X.509 (i.e. oracle/wss11_x509_token_with_message_protection_service_policy). However, I have a requirement that the underlying services (BPEL processes, for example), must know the subject (i.e. the server) that sent the message. For example, did this incoming message come from the HR system or the CRM system. This is used internally by the BPEL process for audit logs and other things.
    We also use OAM, so I will likely eventually use the oracle/wss_oam_token_service_policy to verify ObssoCookie values. In those cases, the underlying Java service or BPEL process will need to have access to the username of the authenticated user.
    I've searched and searched the documentation, and I cannot find any instructions about how to access details about the authenticated subject (such as username, roles, or X.509 properties) from within the protected service, whether it be a Java-based service, a BPEL process, or anything else.
    I did find some information about how to read SOAP header values from within Oracle BPEL processes (see http://chintanblog.blogspot.com/2007/12/insertextract-soap-headers-in-bpel-it.html). However, this looks like it will only work if I use the WSS UsernameToken policy (e.g. oracle/wss_username_token_service_policy), since that is the only policy where the actual subject identifier (username) is specified in a SOAP header.
    Do the other policies (X.509, SAML, and OAM) provide a mechanism to convey properties of the authenticated subject to the underlying service? If so, where is this documented? Thanks much!
    Sincerely,
    Nathan Kopp

    Is it wrong question or wrong thing to do?
    Let's make it a little bit easier/better/worse:
    How can I change policy permissions at runtime?

Maybe you are looking for

  • IND CS3 and Acrobat 9 Pro

    I am working in IND CS3 version 5.0.4 and Acrobat 9 Pro version 9.0.0 Computer: Windows XP Pro, Ver.2002, SP 3 Dell Optiplex GX 620, Pent. D 3GHZ, 3.50GB RAM Question: I am new to the PC environment and have noticed that everytime I double-click an I

  • Finding out the field name from the columns shown on the screen

    Hi, I am new to CRMOD. I see a lot of columns shown on the screen, say in the Account object. Is there a way to find out which column in the Detail screen maps to which exact field in the Admin page ? Appreciate all the help Regards

  • Gridbag layout resize problem

    I have some JLabel, as statusBar, when user diminishes the width of jframe the text of the jlabel is overlapped to the text of other jlabel, therefore the text becomes not leggibile I would want that when the user diminishes the width of the frame, t

  • Insert an email link

    Hi, how may I insert an email link in an adobe rome document ? the "mailto:..." command doesn't work... thanks.

  • Upload Progress

    When uploading files via a browser to a website using Safari, how can I see the progress of my upload? I know the address bar fills with blue, but how can I get more specific information, such as the number of kb left to upload? I'm uploading to a we