Binary Tree Implementations - why both key and value?

Hi there!
I'm sitting here implementing a binary tree, and I was just wondering why most of the binary tree examples encapsulate both a key AND a value in their nodes. Wouldn't it be sufficient to just store comparable objects in the nodes (or provide a comparator for alternative ordering)?
Thanks again, Oliver
P.S.:Any suggestions on good books (free E-Books preferred :-)) on ADTs and algorithms? I'm reading 'Data Structures And Algorithms In Java' by Robert Lafore and not very happy with it (the examples are just plain awful).

Trollhorn wrote:
Hi there!
I'm sitting here implementing a binary tree, and I was just wondering why most of the binary tree examples encapsulate both a key AND a value in their nodes. Wouldn't it be sufficient to just store comparable objects in the nodes (or provide a comparator for alternative ordering)?Yes.
Thanks again, Oliver
P.S.:Any suggestions on good books (free E-Books preferred :-)) on ADTs and algorithms? I'm reading 'Data Structures And Algorithms In Java' by Robert Lafore and not very happy with it (the examples are just plain awful).As online resources:
[http://www.cs.princeton.edu/introcs/44st/]
[http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-006Spring-2008/CourseHome/index.htm]
I don't know of any eBooks on the subject, but I can recommend an excellent hard copy book:
Introduction To Algorithms, by Cormen et al. [http://highered.mcgraw-hill.com/sites/0070131511/information_center_view0/]

Similar Messages

  • Writing the hashtable content (both keys and values) into a text file

    Hello,
    I have a hashtable which have some keys and respective values in it. Now I want to write all thoses content into a text or log file. Can anyone please tell me how to write it.
    thanks,
    chaitanya

    Properties is a subclass of Hashtable. It'll probably work just fine as a drop-in replacement.
    Otherwise...if all keys and values are text, then loop through the Entry objects in the Map in question (Hashtable is a Map, and you probably shouldn't be using Hashtable anyway), or loop through the keys and grab the corresponding value for the keys. Read the API docs for java.util.Map. It's pretty straightforward.

  • OutputText : why both bind and value attribute and other gripes

    Hi
    gripe1
    I have started using creator and I'm a bit confused as to why creator insists on the binding attribute being in place to link the outputText field to the default managed bean -
    like most of us I want to set the value via a resource bundle. ( as shown blelow). If I delete the binding atttribute then outputText Field doesn't get displayed in the Visual Design tab. aaaaaaah!
    <h:outputText binding="#{DemographicInformation.nameLabel}" id="nameLabel" value="#{bundle.userName_label}"/>
    gripe2
    When you declare a resource bundle; either through editing the source directly or dragging from the advanced palette you can't seem to be able place the contained "names" in this the individual outputText field values via value property->bind to object->select from property file. i.e you do don't see to be able to expand the f: loadBundle. This results in a lot of tedious typing
    which I thought this tool was all about preventing!
    Regards
    Daniel

    Re gripe 1:
    Why do you want to remove the binding attribute? The binding attribute has nothing to do with the value - you can certainly display values from resource files without removing the binding attribute. One of the online tutorials (the Sign On example) shows a Creator project using bundle files.
    Re gripe 2:
    The designtime experience for using bundle files in the web app has been improved in the next version of Creator.
    -- Tor
    http://blogs.sun.com/tor

  • Error message display both key and value

    Hi,
    I've an alt key check & if the validation fails then the error message pops-up and displays :
    Error
    JBO-SUB_TYPE_CODE_ALREADY_EXIST: The sub type code already exists.
    I'm not sure why is it displaying the key (JBO-SUB_TYPE_CODE_ALREADY_EXIST:) part also in the message.
    Can someone tell me how to suppress the key part in the error message and just display the message (The sub type code already exists.).
    Thanks,
    -Gaurav

    Hi,
    If you want to avoid the roundtrip to the database you can also create a uniqueKey validator in the Entity Object
    were the AltKey exists. In the failure handling of the validator set the message that you want to be displayed.
    You can see an example of this here: http://www.gabrielsideras.com/2010/09/28/adf-unique-key-validation/
    Gabriel

  • HashMap keys and values not staying consistent (my fault, but why?)

    Alright, after starting out for the very first time with HashMaps a few hours ago, I've gotten the hang of them decently I think. I am encountering a problem, though, when I try to get user-selected keys + values to display. My code is:
       public void useZone(String use)
           Object used = hm.get(use);
           System.out.print("\f");
           Set set = hm.entrySet();
           Iterator i = set.iterator();
           if (used != null){
               System.out.println("Time Zone Used:");
               Map.Entry thiszone = (Map.Entry)i.next();
               Object usedzone = thiszone.getValue(); //Get the value of the zones and assign them as Object usedzone
               Integer useval = (Integer) usedzone; //Assign the Object to an Integer value so we can use it
               difference = useval;
               if (useval > 0){ //Display the hour offset correctly
                   System.out.println(use + ": GMT +" + usedzone.toString());
               else if (useval == 0){
                   System.out.println(use + ": GMT");
               else if (useval < 0){
                   System.out.println(use + ": GMT " + usedzone.toString());
           else{
               System.out.println("Invalid zone name.");
           } //End if
           ClockDisplay.getZone(difference); //Send variable difference
      }What will happen is that the first time I will be fine...
    Say the HashMap keys and values are
    "Rome", "-2"
    "Chicago", "6"
    "New York", "5"
    "Paris", "-1"
    If I type "Rome" in when I execute this method, it gives me the correct output - "Rome: GMT -2"
    If I then re-run the method, as to display a different one, I get "Chicago: GMT -2"
    It's like the name the user inputs is updating, obviously, but the value of the HashMap that goes along with the user-input doesn't match up or something. My code is confusing myself after looking at it for nearly 10 hours, so I apologize that I had to post something so trivial here - I'm sure it's just a problem with my wordings....any help would be greatly appreciated.

    Hello,
    It's very possible I'm missing some things here, but I've attempted to review your code.
    Let me just define the specs of the code as I see them:
    Method useZone accepts String input, which is "supposed" to be the key to a hashmap.
    The timezone offsets are the value's in this hashmap.
    The value is of type Integer.
    If a key is properly selected, print out GMT + or - the offset?
    If I have this correct, consider the following implementation:
       public void useZone(String use) {
           Integer offset = (Integer)hm.get(use);
           System.out.print("\f");
           if (offset != null){
               System.out.println("Time Zone Used:");
               System.out.println(use + ": GMT +" + offset.toString());
           } else{
               System.out.println("Invalid zone name.");
           ClockDisplay.getZone(offset); //Send variable difference
      }I'd guess you're getting odd behavior because you're creating an iterator to iterate through the map, but then only calling i.next() once - HashMap doesn't guarantee insertion order, so the fact it worked once correctly is "random".
    Also, if you are using java 1.5 declare the map as follows:
    Map<String, Integer> hm = new HashMap<String, Integer>();And you can get rid of the casts. I would also suggest renaming the hashmap to something that describes what it holds, rather than it's object type. Maybe something like timeZoneMap - or offsetMap. I would also consider renaming "use" to something that describes the data it might hold, instead of something that describes the workflow.
    Variable naming is very difficult! I would suggest renaming all of your variables, but I think those are the only ones I kept!
    Edited by: Adam_Schaible on Nov 28, 2007 12:09 PM

  • Why does HashMap.java  use transient  for  the collection of key and value?

    I just took a look at source code of HashMap.java.
    It uses the variable "table" to store the keys and values.
    This vairalbe is transient, but any hashmap can be serialized and deserialized.
    Could you please help me clarify how it could happen that the transient variable can be serialized?

    The 'table' might be transient, but its content, or current data content of the map, shoud be somehow saved/restored in the serializing/deserializing code of the HashMap.

  • How to populate both key and text in drop down list in dialog prog screen

    Hi, Can anyone please advice how to display both key and text in the drop down list in dialog prog screen. I tried with below code. keys and texts are getting populated in values table but only text is appearing when click on drop down. need to display both key and text in the drop down. Thanks in advance.
    TABLES: ZRPP_MODELS, ZRPP_FFLSTRATEGY.
    TYPE-POOLS : VRM.
    DATA : field_id TYPE VRM_ID ,
           values   TYPE VRM_VALUES,
           value    LIKE LINE OF values.
    FORM fill_model_list .
      select MODEL MODEL_DESC from ZRPP_MODELS into value.
        APPEND value TO VALUES.
      endselect.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id     = 'ZRPP_MODELS-MODEL'
          values = values.
    ENDFORM.

    You need to concatenate KEY & VALUES
      wa_values-key = '1'.
      wa_values-text = '1 - One'.
      append wa_values to i_values.
      wa_values-key = '2'.
      wa_values-text = '2 - Two'.
      append wa_values to i_values.
      wa_values-key = '3'.
      wa_values-text = '3 - Three'.
      append wa_values to i_values.
      call function 'VRM_SET_VALUES'
        exporting
          id              = 'LIST_BOX'
          values          = i_values
        exceptions
          id_illegal_name = 1
          others          = 2.

  • Iterate thru a HashMap() to view its keys and values

    I need to iterate over the hashmap to view its keys and values
    but the hashmap in 1.5 doesnt return itearor
    is there another way to view the key and value in the hashMap
    HashMap<String, Integer> colMap = new HashMap<String, Integer>();
    String[] array = { "Internal", "Transfer ", "Settle",  };
      List<String> colnames = Arrays.asList(array);
      for (int i = 0; i < cols; i++) {
        if (colnames.contains(headers.get(i))) {
                    colMap.put(headers.get(i), new Integer(i));
      // I need to iterate over this map to get key and values
      // The code below doesnt give me the key and values
         for (Iterator iter = colMap.iterator(); iter.hasNext();)
           Map.Entry entry = (Map.Entry)iter.next();
           String key = (String)entry.getKey();
           String value = (String)entry.getValue();
     

    Maps provide methods called keySet(), values() and entrySet(). Each of those returns a Collection (Set/Collection/Set respectively) that represents a view on the Map. You can get those and get a iterator of that objects.
    If you need both the key and the value in a loop, then you should use the entrySet method.

  • How to set PropertyBag Key and value at farm and sitecollection via PowerShell

    Hi,
    how could i create PropertyBag Key and value at farm and sitecollection via PowerShell?
    Best Regards
    Bog
    Developers Field Notes | www.bog1.de

    Hey, you can do it as follows 
    asnp *sh*
    $site = get-spsite "site url"
    $web = $site.openweb()
    $web.AllProperties["NEW KEY"] = "NEW VALUE"
    $web.update()
    $web.dispose()
    Your new custom property will be present in the web Property bag. 
    and you can access it by $web.AllProperties["New Key"] or simply $web.Properties["New Key"]
    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

  • Please Help::How to display a Map with LIsts as Keys and Values using JSTL

    Hi,
    I need some assistance on how to display a Map in JSP using struts or core JSTL. I have a HashMap which has a List of keys and each key maps to a value of an ArrayList.i.e I have an ArrayList of taxCodes and each taxCode maps to a value of taxDetails which is an ArrayList of details for for that particular taxCode. I have some trouble to display each taxCode then display taxDetails for each taxCode. Here is my code below:
    OrderDetails.java
    package orderitems;
    import java.sql.*;
    import java.util.*;
    public class OrderDetails {
        private LineOder lineOrder;
        private Map lineItems;
        //returns an item number, key_item, from its unique keys
        public int getItemNumber(int key_item, String key_year,
                String key_office,String key_client,String key_company){
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            int itmNum = 0;
             * key_item a unique number for an item.
             * key_year,key_office,key_client,key_company unique keys
             * for each order where this key_item is taken
             * from.
            String select = "SELECT key_item FROM "+
                    Constants.WEB_TABLE +" WHERE key_item = " + key_item +
                    " AND key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company +"'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                if(rst.next()){
                    itmNum = Integer.parseInt(rst.getString("key_item"));
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return itmNum;
        //get a list of item number(item codes)
        public List getAllItemNumbers(String key_year,
                String key_office,String key_client,String key_company){
            List itemNumbers = new ArrayList();
            LineItem itemNumber = null;
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            String select = "SELECT key_item FROM "+ Constants.WEB_TABLE +
                    " WHERE key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company + "'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                while(rst.next()){
                    itemNumber = new LineItem();
                    itemNumber.setKey_item(Integer.parseInt(rst.getString("key_item")));
                    itemNumbers.add(itemNumber);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return itemNumbers;
        //get a list of tax codes
        public List getAllTaxCodes(int key_item, String key_year,
                String key_office,String key_client,String key_company){
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            ItemTax taxCode;
            List taxCodes = new ArrayList();
            int itemNum = getItemNumber(key_item, key_year,
                    key_office,key_client,key_company);
            String select = "SELECT key_tax_code FROM "+
                    Constants.WEB_TABLE +" WHERE key_item = " + itemNum +
                    " AND key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company +"'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                while(rst.next()){
                    taxCode = new ItemTax();
                    taxCode.setKey_tax_code(rst.getString("key_tax_code"));
                    taxCodes.add(taxCode);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return taxCodes;
        /////This methode returns a Map which am trying to display in JSP
        //use tax code to get tax details
        public Map getItemTaxDetails(String key_year,String key_office,
                String key_client,String key_company,int key_item){
            ItemTax taxDetail = null;
            List taxDetails = new ArrayList();
            List itemTaxCodes = new ArrayList();
            Map itemTaxDetails = new HashMap();
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            //get a list of all tax codes of an item with a
            //given item number
            itemTaxCodes = getAllTaxCodes(key_item,key_year,
                    key_office,key_client,key_company);
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
                    ItemTax itemTaxCode = (ItemTax)taxCodeIter.next();
                    String taxCode = itemTaxCode.getKey_tax_code();
                    String select = "SELECT tax_type,tax_value," +
                            "tax_limit_val FROM "+ Constants.WEB_TABLE +
                            " WHERE key_item = "+ key_item +
                            " AND key_year = '" + key_year + "'" +
                            " AND key_office = '" + key_office + "'" +
                            " AND key_client = '" + key_client + "'" +
                            " AND key_company = '" + key_company +"'" +
                            " AND key_tax_code = '" + taxCode + "'";
                    rst = stat.executeQuery(select);
                    while(rst.next()){
                        taxDetail = new ItemTax();
                        //records to be displayed only
                        taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
                        taxDetail.setTax_value(rst.getString("tax_value"));
                        taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
                        //////other details records ommited//////////////////////////
                        taxDetails.add(taxDetail);////An ArrayList of taxDetails for each taxCode
                     * A HashMap which has all taxCodes of an item as its keys
                     * and an ArrayList of taxdetails as its values.
                     * I return this for display in a JSP.
                    itemTaxDetails.put(taxCode,taxDetails);
                System.out.println();
                System.out.println("*********CONSOLE OUTPUT*************");//display on console
                Set set = itemTaxDetails.keySet();
                Iterator iter = set.iterator();
                System.out.println("Key\t\tValue\r\n");
                while (iter.hasNext()) {
                    Object taxCode=iter.next();
                    Object details=itemTaxDetails.get(taxCode);
                    System.out.println(taxCode +"\t" + details);
                System.out.println("************************************");
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return itemTaxDetails;
        //details of an item with all its taxes
        public List getAllItemDetails(String key_year,
                String key_office,String key_client,String key_company){
            List lineItems = new ArrayList();
            List itemNumbers = new ArrayList();
            Map taxDetails = new HashMap();
            LineItem item = null;
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            //A list of all item numbers in the declaration
            itemNumbers = getAllItemNumbers(key_year,
                    key_office,key_client,key_company);
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                for(Iterator itemIter= itemNumbers.iterator(); itemIter.hasNext();){
                    LineItem itemNum = (LineItem)itemIter.next();
                    int itemNumber = itemNum.getKey_item();
                    String select = "SELECT item_description,item_mass," +
                            "item_cost" +
                            " FROM " + Constants.WEB_TABLE +
                            " WHERE key_year = '"+key_year+"'" +
                            " AND key_office = '"+key_office+ "'"+
                            " AND key_client = '"+key_client+ "'"+
                            " AND key_company = '"+key_company+ "'"+
                            " AND key_item = " + itemNumber;
                    rst = stat.executeQuery(select);
                    while(rst.next()){
                        item = new LineItem();
                        item.setItem_description(rst.getString("item_description"));
                        item.setItem_mass(Float.parseFloat(rst.getString("item_mass")));
                        item.setKey_item(Integer.parseInt(rst.getString("item_cost")));
                        //////other details records ommited//////////////////////////
                        /* A HashMap of all itemTaxeCodes as its keys and an
                         * ArrayList of itemTaxedetails as its values
                        taxDetails = getItemTaxDetails(item.getKey_year(),item.getKey_office(),
                                item.getKey_client(),item.getKey_company(),item.getKey_item());
                        //item tax details
                        item.setItmTaxes(taxDetails);
                        //list of items with tax details
                        lineItems.add(item);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return lineItems;
        public Set getOrders(String key_year,String key_office,
                String key_client,String key_company){
            List lineItems = new ArrayList();
            Set lineOrders = new HashSet();
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            LineOder lineOrder = null;
            String select = "SELECT * FROM " + Constants.WEB_TABLE +
                    " WHERE key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company + "'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                while(rst.next()){
                    lineOrder = new LineOder();
                    lineOrder.setKey_year(rst.getString("key_year"));
                    lineOrder.setKey_office(rst.getString("key_office"));
                    lineOrder.setKey_client(rst.getString("key_client"));
                    lineOrder.setKey_company(rst.getString("key_company"));
                    ////list of items with all their details
                    lineItems = getAllItemDetails(lineOrder.getKey_year(),lineOrder.getKey_office(),
                            lineOrder.getKey_client(),lineOrder.getKey_company());
                    //setting item details
                    lineOrder.setItems(lineItems);
                    //a list of order with all details
                    lineOrders.add(lineOrder);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return lineOrders;
    Controller.java
    package orderitems;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Controller extends HttpServlet {
        private Map taxDetails = new HashMap();
        private OrderDetails orderDetails = null;
        protected void processRequest(HttpServletRequest request,
                HttpServletResponse response)throws
                ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            String key_year = "2007";
            String key_office = "VZX00";
            String key_company = "DG20";
            String key_client =  "ZI001";
            int key_item = 1;
            String nextView = "/taxdetails_list.jsp";
            orderDetails = new OrderDetails();
            taxDetails = orderDetails.getItemTaxDetails(key_year,key_office,
                    key_company,key_client,key_item);
            //Store the collection objects into HTTP Request
            request.setAttribute("taxDetails", taxDetails);
            RequestDispatcher reqstDisp =
                    getServletContext().getRequestDispatcher(nextView);
            reqstDisp.forward(request,response);
        protected void doGet(HttpServletRequest request,
                HttpServletResponse response)throws
                ServletException, IOException {
            processRequest(request, response);
        protected void doPost(HttpServletRequest request,
                HttpServletResponse response)throws
                ServletException, IOException {
            processRequest(request, response);
    taxdetails_list.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <title>Simple Tax Detail Diaplay ::</title>
            <link rel="stylesheet" type="text/css" href="imgs/orders.css"/>
        </head>
        <body>
            <jsp:useBean id="taxDetails" class="java.util.HashMap" scope="request"/>
            <table>
                <c:forEach items="${taxDetails}" var="hMap">
                    <tr>
                        <td><c:out value="${hMap.key}" /></td>
                        <!--td><%--c:out value="${hMap.value}" /--%></td-->
                    </tr>
                </c:forEach>
            </table>
        </body>
    </html>am displaying taxCodes(in this case i have VAT and ICD) fine but cant figure out how to display a list of value for each taxCode.Here is the output am getting
    both in my JSP and on the console:
    *******************************CONSOLE OUTPUT****************************
    Key          Value
    ICD     [orderItems.ItemTax@13e6226, orderItems.ItemTax@9dca26]
    VAT [orderItems.ItemTax@13e6226, orderItems.ItemTax@9dca26]
    Edited by: aiEx on Oct 8, 2007 6:54 AM

    hi evnafets,
    yes i need a nested for loop.I have tried your advice but my bean properties are not found.Am getting this error:
    javax.servlet.ServletException: Unable to find a value for "key_item" in object of class "java.lang.String" using operator "."
    I have tried this as stated earlier in the post:I have tried to make the method getItemTaxDetails return a List and get the returned list value as taxDetails. I then tested to display this list on JSP and its displaying fine.
    public List getItemTaxDetails(String key_year,String key_office,
                String key_client,String key_company,int key_item){
            ItemTax taxDetail = null;
            List taxDetails = new ArrayList();
            List itemTaxCodes = new ArrayList();
            Map itemTaxDetails = new HashMap();
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            //get a list of all tax codes of an item with a
            //given item number
            itemTaxCodes = getAllTaxCodes(key_item,key_year,
                    key_office,key_client,key_company);
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
                    ItemTax itemTaxCode = (ItemTax)taxCodeIter.next();
                    String taxCode = itemTaxCode.getKey_tax_code();
                    String select = "SELECT tax_type,tax_value," +
                            "tax_limit_val FROM "+ Constants.WEB_TABLE +
                            " WHERE key_item = "+ key_item +
                            " AND key_year = '" + key_year + "'" +
                            " AND key_office = '" + key_office + "'" +
                            " AND key_client = '" + key_client + "'" +
                            " AND key_company = '" + key_company +"'" +
                            " AND key_tax_code = '" + taxCode + "'";
                    rst = stat.executeQuery(select);
                    while(rst.next()){
                        taxDetail = new ItemTax();
                        //records to be displayed only
                        taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
                        taxDetail.setTax_value(rst.getString("tax_value"));
                        taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
                        //////other details records ommited//////////////////////////
                        taxDetails.add(taxDetail);////An ArrayList of taxDetails for each taxCode
                     * A HashMap which has all taxCodes of an item as its keys
                     * and an ArrayList of taxdetails as its values.
                     * I return this for display in a JSP.
                    itemTaxDetails.put(taxCode,taxDetails);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            //return itemTaxDetails;
            return taxDetails;
        }And my JSP
    taxdetails_list.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <link rel="stylesheet" type="text/css" href="imgs/orders.css"/>
        </head>
        <body>
            <table>
                <c:forEach var="curRecord" items="${taxDetails}" varStatus="rowCounter">
                        <c:choose>
                            <c:when test="${rowCounter.count % 2 == 0}">
                                <c:set var="rowStyle" scope="page" value="odd" />
                            </c:when>
                            <c:otherwise>
                                <c:set var="rowStyle" scope="page" value="even" />
                            </c:otherwise>
                        </c:choose>
                        <tr class="${rowStyle}">
                            <td>${curRecord.key_item}</td>
                            <td>${curRecord.tax_value}</td>
                            <td>${curRecord.tax_limit_val}</td>
                        </tr>
                    </c:forEach>
            </table>
        </body>
    </html>I can't see where am going wrong even with your advice.Please help.
    Thnx.

  • A Binary Tree Implementation in ABAP

    Hi,
    Can any one explaine me how to create a binary tree of random numbers with dynamic objects.
    Thanks,
    Manjula.

    Hi manjula,
    This sample code uses dynamic objects to create a binary tree of random numbers as per your requirement ...pls go through It. 
    It stores numbers on the left node or right node depending on the value comparison with the current value. There are two recursive subrotines used for the building of the tree and printing  through the tree.
    For comparison purpose, the same random numbers are stored and sorted in an internal table and printed.
    *& Report YBINTREE - Build/Print Binary Tree of numbers *
    report ybintree .
    types: begin of stree,
    value type i,
    left type ref to data,
    right type ref to data,
    end of stree.
    data: tree type stree.
    data: int type i.
    data: begin of rnd occurs 0,
    num type i,
    end of rnd.
    start-of-selection.
    do 100 times.
    generate random number between 0 and 100
    call function 'RANDOM_I4'
    exporting
    rnd_min = 0
    rnd_max = 100
    importing
    rnd_value = int.
    store numbers
    rnd-num = int.
    append rnd.
    build binary tree of random numbers
    perform add_value using tree int.
    enddo.
    stored numbers are sorted for comparison
    sort rnd by num.
    print sorted random numbers
    write: / 'Sorted Numbers'.
    write: / '=============='.
    skip.
    loop at rnd.
    write: rnd-num.
    endloop.
    skip.
    print binary tree. This should give the same result
    as the one listed from the internal table
    write: / 'Binary Tree List'.
    write: / '================'.
    skip.
    perform print_value using tree.
    skip.
    *& Form add_value
    text - Build tree with value provided
    -->TREE text
    -->VAL text
    form add_value using tree type stree val type i.
    field-symbols: <ltree> type any.
    data: work type stree.
    if tree is initial. "When node has no values
    tree-value = val. " assign value
    clear: tree-left, tree-right.
    create data tree-left type stree. "Create an empty node for left
    create data tree-right type stree. "create an empty node for right
    else.
    if val le tree-value. "if number is less than or equal
    assign tree-left->* to <ltree>. "assign the left node to fs
    call add_value recursively with left node
    perform add_value using <ltree> val.
    else. "if number is greater
    assign tree-right->* to <ltree>. "assign the right node to fs
    call add_value recursively with right node
    perform add_value using <ltree> val.
    endif.
    endif.
    endform. "add_value
    *& Form print_value
    text - traverse tree from left-mid-right order
    automatically this will be sorted list
    -->TREE text
    form print_value using tree type stree.
    field-symbols: <ltree> type any.
    if tree is initial. "node is empty
    else. "non-empty node
    assign tree-left->* to <ltree>. "left node
    perform print_value using <ltree>. "print left
    write: tree-value. "print the current value
    assign tree-right->* to <ltree>. "right node
    perform print_value using <ltree>. "print right
    endif.
    endform. "print_value
    pls reward if helps,
    regards.

  • Pie chart with both text and value

    Hi,
    I want the pie chart to contain both the text and value how is this possible when I look at the optiond for chart I was able to select only one thing at a time both not both the things at a time ,please let me know how is this possible
    Thanks
    Priya

    Hi Priya,
    this should be possible. In the Chart Designer in the properties of the Categories you must edit the Format string to e.g. "$Label$br0.00" (show the label, make a line break, show the value with 2 decimals). For more info regarding the format string see note <a href="http://service.sap.com/sap/support/notes/1064448">1064448</a>.
    Best regards
    Matthias

  • Member.getID(), Member.getUID(), Members as cluster cache keys and values

    My cluster application needs to do some bidirectional mappings via coherence between
    coherence members and application entities.
    What we have now are mappings that use Member.getID() integers.
    When we need to dispatch logic to Members hosting an entity
    we'll use InvocableService.{execute,query}() with a member set derived by use of
    ServiceInfo.getServiceMember() for the int member ID's we have.
    My concern is that if we have delays or other snafus in membership event processing
    that the member id's returned by getID() will be recycled and refer to a different cluster member.
    For example, if our event listener is down for some time, when it comes back up there may be
    entries in the cache whose member ID's were recycled, at least that's my fear.
    For our logic that would be bad. We'd assume we had entity assignment to a member
    that has actually disappeared.
    I could potentially use Member.getUID(), but that doesn't guarantee a unique
    identifier, and so like a hash I wouldn't use it as the sole key where an unambiguous
    resolution is required.
    I was just looking for advice on anternatives or pitfalls of having caches
    keyed or valued by cluster Members in whatever way works best.
    We have a set of resources where want to apply our own membership distribution policies
    according to a complex algorithm applied to whatever the cluster topology du jour may be,
    so just allowing coherence maps to do the partitioning for us is not an option in this case.

    I haven't had any problems with it yet, but the facility is still in development.
    Being armed with a bit more information now can save a lot of headaches later.
    The information you provided should be enough to help me avoid problems.
    The only issue for me being that we're still running version 3.5, but presumably the UID format
    you described was the same in 3.5 too.
    Thanks much!

  • Binary Tree Implementation

    Hi,
    How to implement Binary search tree in java?
    How to create node & how to do backtracking?
    Thanks & Regards,
    Sathyavathy S

    Pretty much like in most other OO languages.
    What exactly is your problem? Do you have a bug in your code, a compiler error or don't you understand how a binary tree works?

  • Why both jpeg and dng from my D90?

    OK ....bear with me - I'm a beginner ... but why do I get photos from my Nikon D90 in both jpeg and dng formats? Is this desirable? Can I just select the dng format? If so, how?
    And really confusing to me is the fact that often the jpeg copies seem to be more vibrant than its dng brother.
    Thanks, Burt

    Burtman,
    First, your user manual will tell you how, in the camera's menu, to choose whether you want RAW, small RAW, JPEGs in Large, Medium, or Small, and a combination of RAW and JPEG.
    Now, the why:  RAW files are specifically intended for those who plan on doing image processing after taking the picture...it is what you camera's sensor actually "sees" and when comparedto the JPEG will almost always look washed out as you are seeing.  If you are not planning on doing intensive post-processing such as white balance corrections, or using these as the kick-off point for creating large image files (such as TIFs coming out of Photoshop) that are not destined for large format printing, you may well find that (at least for now) you are fine just changing the file capture setting just to Large JPEGs.
    Here is a link to the manual (you want the section starting on page 62), but the short version is:  use the "quality" button on the bottom left of the back of the camera, and then use the main command dial to change selections.
    Link to user manual.
    Hope that helps.
    H

Maybe you are looking for

  • HTTP error 500: Internal server error: In OAC0 tcode - CS Admin button.

    Hi, In our ecc system, when I go to OAC0 TCode and click the button CS Admin, it does open the page "Content Server administration" but on the bottom bar I always see error "HTTP error 500: Internal server error". I want to know if this is normal. We

  • How Can i override a target for a monitor in a sealed Management pack

    Hello everyone,          I have very generic question here, May be it is too basic.  I have a time Skew Monitor that is present from an AD MP which is targeted to only AD Computers. Now overriding this Monitor to ALL computers , will this monitor fun

  • Problems with input accented characters after moving JInitiator to JDK 1.5

    After upgrading from JInitiator 1.3.1.18 to JDK 1.5.0_06 (jdk plugin in IE), the input of accented characters (in our case portuguese) isn't working anymore in text areas on the forms (Forms 10g). So, if you push first the "´" key and then the "a" ke

  • Excel Template - Node in Tree

    Hello, I am creating an Excel Template and I am trying to figure out how to display data for the first node in the tree (the first node in my sample XML file). I looked at this website (http://bipconsulting.blogspot.com/2009/03/xslxpath-for-bi-publis

  • Security questions problem

    hello, I forgot my security answers in app store and they sent E-mail to reset question, but i didn't receive any E-mail form them. Please can anybody help me to reset my security answers ..? Thank you..