Shopping cart!! Retriving values from Hashtable?

Hi,
Could you please help me solve this problem?
I am adding some values to the Hashtable. For every time I add the server is definitely showing
me that some thing is added to the Hashtable. But when I try to print the values present in
Hashtable, I do not see any thing on the browser other than "table headers" ? Can any one help
me?
Here are the codes
ShopBean.java
import java.util.*;
import java.lang.*;
public class ShopBean
     private Hashtable hashtable = new Hashtable();
     public ShopBean()
     public void addToCart(String itemid,String name,float price,int quantity)
          String[] items = {itemid,name,Float.toString(price),Integer.toString(quantity)};
          if(hashtable.containsKey(itemid))
               String[] tmpItem = (String[])hashtable.get(itemid);     
               int tmpQuantity = Integer.parseInt(tmpItem[3]);
               quantity += tmpQuantity;
               tmpItem[3] = Integer.toString(quantity);
          else
               hashtable.put(itemid,items);
     public Enumeration getEnumeration()
          return hashtable.elements();
Tibre.java
public class Tibre extends HttpServlet
     String user,s1,s2,s3,s4,s5,s6,s7,prev,next,flag;
     int i,count=0,i1,i2,i3,i4,records=0,from,to,no,rem,k,c;
     public void doGet(HttpServletRequest req,HttpServletResponse res)
          doPost(req,res);
     public void doPost(HttpServletRequest req,HttpServletResponse res)
          try
               ServletOutputStream sos = res.getOutputStream();
               HttpSession ses = req.getSession(true);
               user=(String)ses.getValue("user");
               ShopBean cart = new ShopBean();
               String id = req.getParameter("id");
               if(id != null)
                    String name = req.getParameter("name");
                    Float price = new Float(req.getParameter("price"));
                    cart.addToCart(id,name,price.floatValue(),1);
                    System.out.println("cart values in tibre.java"+cart);
               sos.println("<html>");
               sos.println("<body bgcolor=lightyellow>");
               sos.println("<p>Welcome to Online shopping "+user+" , Please see the
gallery of items.</p>");
               sos.println("<table border='1' cellspacing='1' width='41%'
cellpadding='2' id='AutoNumber1'>");
               sos.println("<tr>");
                    sos.println("<td width='21%'>");
                    sos.println("<img border='0' src='images/11.gif' width='120'
height='150'>   ");
                    sos.println("</td>");
                    sos.println("<td width='79%'>");
                    sos.println("<img border='0' src='images/22.gif' width='120'
height='150'></td>");
               sos.println("</tr>");
               sos.println("<tr>");
               sos.println("<form method='post'
action='http://localhost:8080/servlet/Tibre'>");
                    sos.println("<td width='21%'>$300 <input type=submit value='Add
to Cart' name=tibre1>");
                    sos.println("</td>");
                    sos.println("<input type='hidden' value='100' name='id'>");
                    sos.println("<input type='hidden' value='Tibre' name='name'>");
                    sos.println("<input type='hidden' value='300.89' name='price'>");
                    res.sendRedirect("http://localhost:8080/servlet/Tibre");
                    sos.println("</form>");
                    sos.println("<form method='post'
action='http://localhost:8080/servlet/Tibre'>");
                    sos.println("<td width='79%'>$800.99 <input type=submit
value='Add to Cart' name=tibre2>");
                    sos.println("</td>");
                    sos.println("<input type='hidden' value='200' name='id'>");
                    sos.println("<input type='hidden' value='Compaq' name='name'>");
                    sos.println("<input type='hidden' value='800.99' name='price'>");
                    res.sendRedirect("http://localhost:8080/servlet/Tibre");
                    sos.println("</form>");
               sos.println("</tr>");
               sos.println("</table>");
               sos.println("<a href='http://localhost:8080/servlet/ViewCart'>View
Cart</a>");
               sos.println("</body>");
               sos.println("</html>");
          catch(Exception e)
               e.printStackTrace();
ViewCart.java // When I click viewcart I should display the contents from the hashtable
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class ViewCart extends HttpServlet
     public void doGet(HttpServletRequest req,HttpServletResponse res)
          try
               ServletOutputStream sos = res.getOutputStream();
               ShopBean cart = new ShopBean();
               sos.println("<html><head>");
               sos.println("<title> Shopping Cart Contents</title>");
               sos.println("</head>");
               sos.println("<body bgcolor=lightyellow>");
               sos.println("<table border='1' width='300' cellspacing='0'
cellpadding='2' align='center'>");
               sos.println("<caption><b>Shopping cart contents</b></caption>");
sos.println("<tr><th>description</th><th>Price</th><th>Quantity</th></tr>");
               Enumeration enum=cart.getEnumeration();
               String[] tmpItem;
               while(enum.hasMoreElements())
                    tmpItem=(String[])enum.nextElement();
                    sos.println("<tr>");
                    sos.println("<td>"+tmpItem[1]+"</td>");
                    sos.println("<td align='center'>"+tmpItem[2]+"</td>");
                    sos.println("<td align='center'>"+tmpItem[3]+"</td></tr>");
               sos.println("</table>");
               sos.println("</center>");
               sos.println("<a     href='http://localhost:8080/servlet/Tibre'>Back to
Catalog</a>");
               sos.println("</body>");
               sos.println("</html>");
          catch(Exception e)
               e.printStackTrace();
Also please correct me if there are any mistakes in my code.
Thanks for any help
Uma

Few errors,
1.Your 'addToCart' method in the bean will not work as you are thinking. Try to find out the reason by yourself.
2.ShopBean cart = new ShopBean(); in your ViewCart servlet gives you a fresh bean with a blank hashtable. Obviously it will not contain any items and hence you are not getting them displayed in the browser. Again you need to find out the error, I can give you a clue, Insert an item in the bean's constructor and test your code.
3.You need to carry the information between your servlets, session is the best thing to use. So, your bean's scope must be session.
Try to solve it by yourself, this forum will always be there to guide you.
Hope this helps.
Sudha

Similar Messages

  • Limit Shopping cart not cleared from sourcing.

    Hi All,
    We have an issue with the Limit shopping carts in sourcing. After the folllow on document [PO] is created successfully through Sourcing, the SC still shows up in the sourcing cockpit. The job BBP_GET_STATUS2 is running properly. In BBP_PD, we have the status I1113 - Follow-on Document Created.
    This happens only to the limit Shop.Carts and the normal SCs are cleared from the sourcing cockpit, as soon as the PO is created.
    Any suggestions?
    Thanks!

    As per standard after creating folow on document , the sc should not stay in cockpit/
    is it happening for all cart?
    what is the sourcing indicator value for that cart
    br
    muthu

  • POs upon saving shopping cart (sourced) v from SOCO in classic

    Hi,
    Is there any way I can differentiate POs created directy upons saving shopping cart(sourced SC) & PO created in back end from SOCO in classic scenario.
    Is there any table where I can look for this?

    CREATED BY REQUESTER name - if FIXED source of supply
    CREATED BY BUYER name - if come from cockpit.
    SAP Note 1436207 - Change Document: Backend PO with
    incorrect creator
    Symptom
    A follow-on document is created from a requirement in the 'Sourcing
    Cockpit'. When you display the change document of this requirement, the
    system will display the last changer of this document as a creator of the
    follow-on document.
    The above are clues and you can look up tables and validatons
    Muthu

  • Cost distribution in shopping cart by value

    Hi,
    I have a problem with the limit shopping cart in SRM 5.5 with ECC6 as backend. When we create the limit shopping cart and distribute the cost assignment by value we are getting the error message in RZ20:
    Shopping cart 1000005030 (PReq. ): BBP_BD 002 Buffer table not up to date.
    Then in BBP_PD Table   BBP_PDBEI and in the field BE_OBJECT_ID we only get the value of                         1 So the purchase order nevers created and the shopping cart is in limbo.
    Does anyone have nay experience of this error?
    Thanks Andrew

    1317756 and 1353124 note may help you

  • Copy shopping cart item (originally from catalog), able to change price

    We create a shopping cart item by selecting a catalog item from CCM 2.0. The price is not changeable, as we would expect.
    We then copy that item in the cart to create item 2. However, the price in item 2 is now changeable, even though it was copied from catalog item 1.
    We have implemented OSS note 693175 which gives us the ability to change the price of a catalog zero priced item, which is what we want.
    But we do not want to be able to amend the price of catalog items that have been copied to new items.
    Can we prevent a catalog item that has been copied from having its price changed?
    Thanks
    Neil

    Hi Neil,
    I think any item that is copied from another line item can be changeable irrespective of whether the first item was a catalog item or not.
    You are just copying a line item and is not directly taken from catalog.
    So the system allows you to change the item details.
    If you want to order the same item at same price then what is the need for copying it as second line item.
    Hope this makes you clear.
    Rgds,
    Teja

  • Delete shopping cart in bulk from GUI

    Hi,
    Is it possible to delete or to confirm item in shopping cart from GUI? Does anybody know about this. Fyi, I want to remove 1000 lines of shopping cart from GUI. Is there a way to do this?
    Thanks and regards,
    HH

    Dear Poster,
    As no response has been provided to the thread in some time I must assume the issue is resolved, if the question is still valid please create a new thread rephrasing the query and providing as much data as possible to promote response from the community.
    Best Regards,
    SDN SRM Moderation Team

  • Htmlb:Retrive values from bean n display it in textView

    Hi,
    I am doing one PDK application using jspdyn page. In jsp page I am using htmlb to display the table. In that I am using one text view element. There I need to get the values from bean class.And display it in a table.
    Can anyone help me how can use the textView inside htmlb to retrieve the values from bean.
    Thanks & Regards
    Vineela

    hi vineela,
    check this
    https://www.avispublics.com/irj/portalapps/com.sap.portal.pdk.htmlb.htmlbmanuals/docs/dynpage-01.html
    https://ww2.avispublicsduparisien.com/irj/portalapps/com.sap.portal.pdk.htmlb.htmlbmanuals/docs/tableview-01.html
    bvr
    Edited by: bvr on Mar 4, 2009 12:06 PM

  • Problem in Retrive values from result set

    I have a class where i do all database operation .First i fire select query and take values from result set and based on that value i fire update query.
    Problem is that i am not getting all values from result set . i get only last value and when i fire update query i get error as :Resultset is closed.
    I am using acess and java.

    You probably are using the same Statement object for both queries? Try creating separate Statement objects for each query. (My guess is this a problem with the way you're using JDBC, not a Servlet issue.)

  • Should the vendor in the Shopping Cart be updated from the Sourcing Cockpit

    Hi All,
    hopefully an easy question for someone to answer.
    When a vendor is assigned in the Sourcing Cockpit and the Purchase Order is created should the vendor be updated in the linked shopping cart?
    Cheers
    Chris

    Hi Chris,
    All questions are welcome irrespective of the criticality so you are free to ask anything related to SRM.
    The vendor will not get updated in the shopping cart if you assign a vendor at the time of sourcing while creating a P.O. The same can be checked out by selecting the Source of supply / service agents link in the check status for a particular shopping cart.
    The source of supply field will only be populated when you assign the vendor at the shopping cart level and not during the P.O creation.
    Hope this will make you clear.
    Rgds,
    Teja

  • MySAP SRM/EBP Shopping Cart(move workitem from 'Approval' to 'Message' tab)

    when an employee creates an incomplete shopping cart in EBP (web based) an appropriate workflow is started in R/3 backend, creates a workitem and shows under 'Approval' tab of the web application. The requirement is it should show the work item under 'Messages' tab. Any help is highly appreciable.

    Hi Masa,
           Earlier all the notification emails and workitems of incomplete shopping cart were under message tab & remaining all other workitems were under approval tab.
    Now only notification emails are shown under message tab and all workitems under approval tab. Client wants the former functionality back.
    Cheers!!
    Gopinath

  • How to retrive value from SVG and put in XLS(excel) file ?

    Hello all,
    I ll appreciate you if you help me in this issue,
    My Project Manager give me a task of creating a java program to take values from SVG file and put that data into a particular cell.
    Can you give me some favourable hints to help in this issue.
    Thanks in advance.
    Jaison

    If by "array format" you mean comma-separated, why not
    FOR x IN v_searchResult.FIRST .. v_searchResult.LAST
    LOOP
    v_id := v_id || TO_CHAR(v_searchResult(i).Product_ID);
    END LOOP;or even better....
    FOR x IN v_searchResult.FIRST .. v_searchResult.LAST
    LOOP
        IF x =  v_searchResult.FIRST
        THEN
           v_id TO_CHAR(v_searchResult(x).Product_ID);
        ELSE
           v_id := v_id ||','|| TO_CHAR(v_searchResult(x).Product_ID);
        END IF;
    END LOOP;Cheers, APC

  • Retriving value from Pie chart to hidden field using onmouseover event

    Hi,
    I am Vaibhav. I have create Pie chart on EMP table. Pie chart query is as follows,
    SELECT 'javascript:onmouseover=$x(''P25_DEPTNO'').value='||deptno||';popupURL(''http://www.google.com'');' LINK,
    deptno, COUNT (empno)
    FROM emp
    GROUP BY deptno
    On mouseover on Pie chart i want to get value of deptno column but from above query i am not getting the value of deptno. So how should I get value of deptno on mouseover event on Pie chart.
    Thanks in advance,
    Regards,
    Vaibhav
    Edited by: user10600404 on Feb 28, 2011 10:39 PM

    Hi,
    I can get it to work with:
    SELECT 'javascript:onclick=$x("P24_DEPTNO").value='||deptno||';popupURL("http://www.google.com");' LINK,
    deptno, COUNT (empno)
    FROM emp
    GROUP BY deptno That is - using onclick instead of onmouseover.
    See: http://apex.oracle.com/pls/otn/f?p=9568:24 - the Select list is updated as you click on a slice in the pie chart
    Andy

  • How to retrive value from column of type number

    Hi,
    I have a site column 'Sample' which is of type Number. Number of decimal places for the column is specified as 0.
    Consider the Sample column has a value '2'.
    When I retrieve the properties for Sample column, the value is displayed as 2.0000000
    I am retrieving the listitem properties using SPListItem.Properties in ItemCheckedin event.
    How to get value without the decimal places?
    Thanks in advance,
    dhijit

    Hi.
    You can cast this value as int.
    int myVal = (int)myItem["myField"];
    if cast crashes, try to use int.TryParse or Convert.ToInt32 Mehods
    Regards,
    Bubu
    http://zsvipullo.blogspot.it
    Please mark my answer if it helped you, I would greatly appreciate it.

  • PO Custom Field not getting filled from Shopping Cart

    Hi Gurus,
    I am new to SRM. The requirement I had was to add a new field to the SC. I read several posts and articles on this but couldn't find the solution to it. I managed to do this modifying the corresponding structures in SRM and making the necessary changes in R/3 so the new filed can be seen in ME21/22/23N.
    I checked Andreas Milbredt document to achieve it as mentioned:
    Document: How to transfer custom fields from SRM to Backend.
    http://www.sdn.sap.com/irj/sdn/index?rid=/library/uuid/20b36c12-685f-2c10-4fb4-ba2e0b969c27
    After that, when I create a Shopping Cart, the value in the New field is not transferred to the Back end.
    I coded the following BADIs and User Exits:
    In SRM:
    BBP_CUF_BADI_2 (MODIFY_SCREEN) ->To enable or disable the field depending on conditions. Works fine.
    BBP_DOC_CHECK_BADI (BBP_DOC_CHECK) -> To do some checks. Works Fine
    BBP_CREATE_BE_PO_NEW (FILL_PO_INTERFACE1) ->Here I fill structures BAPI_TE_MEPOITEM and BAPI_TE_MEPOITEMX. I added another u2018Xu2019 to indicate the new field to BAPI_TE_MEPOITEMX. But I think I am not doing it right. This structure BAPI_TE_MEPOITEM/X, does the order of the fields correspond to the order of the fields in any of these 3 structures (which I am using)?
    INCL_EEW_PD_HISTORY_CSF
    INCL_EEW_PD_ITEM_CSF
    INCL_EEW_PD_ITEM_CSF_SC
    I also checked the following link:
    Map a custom SRM field to a standard field in R/3
    In R/3 I populated the Exits Andreau2019s mentions on his article. Am I missing anything else?
    Thanks & Regards,
    Ernesto.

    Hi Ernesto,
    You can find out how your BAPI structure is being populated (by generating the test data ) using FBGENDAT program and activating the BAPI_PO_CREATE1 (and you will need to set the parameter for the specified user id)... This will provide you ability to execute the BAPI offline and figure out what is happening...
    Note 517767 - Generate test data for function modules
    Things to look for, Is any of your custom fields quantity fields or integer?
    Check out the following OSS note
    Note 509898 - BAPI enhancement concept and Unicode
    Also check out the following SDN Thread,
    problem using  BAPI_BUS2001_CREATE to create project definition
    Check out a similar thread that we are discussing (for PR)
    Custom Fileds Data Was Not Getting Updated In BAPI_PR_CREATE

  • Shopping Cart needs to be Held Status when created from Upload Program

    Hi All,
    Shopping Cart is created from Custom Upload Program. In Upload Program, we used BBP_PD_SC_CREATE, BBP_PD_SC_UPDATE, BBP_PD_SC_SAVE and BBP_PD_SC_COMMIT.
    Once the Shopping Cart is created from this upload program, I want ot put Shopping Cart as Helad Status.
    I exported the parameter I_PARK as 'X' in BBP_PD_SC_CREATE and BBP_PD_SC_UPDATE. But it is not working i.e., the SRM system is not keeping the Shopping Cart as Held Status.
    Scenario:
    I am uploading the Shopping Cart Items (Shopping Cart creation) on behalf of my manager. My manager has to approve Shopping Cart.
    If shopping cart is created maually and Shopping cart value is within the spending limit, work flow is not triggered approval proceess. If I am creating shopping cart behalf of some one, I am adding the approver manually while creating.
    When ever we create shopping cart through custom upload program, the shopping cart needs to be approved by the Requestor (my manager, to cross check shopping cart items). So I want to park the Shopping Cart and I want to add Approver as my manager.
    Please suggest me or guide me to get the solution for my issue.
    Thanks,
    Sudarsan
    Edited by: KOYYA SUDARSANA NAIDU on Nov 14, 2008 9:12 PM

    Completed

Maybe you are looking for

  • Converting a given string to non-english language

    {color:#0000ff}Hi can anybody help me how to convert an entered string in textfield to french or spanish or to anyother non-english language?{color}

  • Account assignment category F not showing in PR & PO for stock material.

    Dear All, I have created one breakdown maintenance order in that i have planned one stock (L) material, for this reservation is created. Then i have run mrp by using tcode md03 for that material.......pr is generated. Now when i am going to convert t

  • HTTP/1.1 500 Internal Serve

    Trying to login with firefox 3.6.23 causes below. HTTP/1.1 500 Internal Server Error Date: Tue, 18 Oct 2011 20:50:15 GMT Server: Oracle-Application-Server-10g Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 28

  • Instalation bussiness connector 4.8

    Someone have Business Connector 4.7 CDu2019s or some URL to download it. Thanks

  • Stop Xerces to resolve Entities

    Hi, 1) Question: ============ I've got the following problem. In one of my swing-projects i need the possiblity to edit XML-Code. Now when reading in the XML-File Xerces expands ENTITITES like & and in my Swing-App only & is shown. I have not found a