Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: retrieving hashmap data in table format based key values

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default retrieving hashmap data in table format based key values

    hi i have define hashmap like this in java class
    public static HashMap<String,List<String>> taskMgmt()
    	{
    		HashMap<String,List<String>> m=null;
    	try
    	{
    		List<String> list = new ArrayList<String>();
    		list.add("AddConference");
    		list.add("Registration");
    		list.add("UpdateConference");
    		list.add("DeleteConference");
    		list.add("Login");
    		list.add("webScraping");
     
    		List<String> list1 = new ArrayList<String>();
    		list1.add("9th Apr,2013");
    		list1.add("10th Apr,2013");
    		list1.add("11th Apr,2013");
    		list1.add("12th Apr,2013");
    		list1.add("13th Apr,2013");
    		list1.add("14th Apr,2013");
     
    		List<String> list2 = new ArrayList<String>();
    		list2.add("9th Apr,2013");
    		list2.add("10th Apr,2013");
    		list2.add("11th Apr,2013");
    		list2.add("12th Apr,2013");
    		list2.add("13th Apr,2013");
    		list2.add("14th Apr,2013");
     
    		List<String> list3= new ArrayList<String>();
    		list3.add("1d");
    		list3.add("2d");
    		list3.add("1d");
    		list3.add("2d");
    		list3.add("1d");
    		list3.add("3d");
    		m=new HashMap<String,List<String>>();
     
    		m.put("name", list);
     
    		m.put("start",list1);
     
    		m.put("end",list2);
     
    		m.put("duration",list3);
     
    		System.out.println("HashDao"+m);
    	}
    	catch(Exception e)
    	{
    		e.printStackTrace();
    	}
     
    	return m;
    	}
     
     
    }
    so i need this map data into jsp page in table format

    for this i have written jsp code like

    <table border=1 ><tr><th>Name<th></th><th>Duration</th><th>StartDate</th><th>EndDate</th></tr>
    <%
    HashMap<String,List<String>> loans=ListDao.taskMgmt();
    Set<Map.Entry<String, List<String>>> entrySet = loans.entrySet();
    for (Entry entry : entrySet) {%>
    <tr><td><%=entry.getKey() %></td><td><%=entry.getValue() %></td></tr>

    <%} %>
    </table>
    i need the data like i defined in table headers please help


    thanks in advance


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,541
    My Mood
    Hungover
    Thanks
    145
    Thanked 648 Times in 553 Posts

    Default Re: retrieving hashmap data in table format based key values

    What type of value is returned from entry.getValue()? How do you want to display that value?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: retrieving hashmap data in table format based key values

    in value i have put list type of data so i need this data in the follwing format
    name duration startdate enddate
    ----- -------- ----------- -----------
    Addconference 1d 9th apr, 2013 15th apr, 2013
    registartion 2d 10th apr,2013 14th apr,2013
    ------------------------------------------
    -------------------------etc
    but am getting the data in the follwing format

    name[addconfeence,registarion]
    duration[1d,2d]
    startdate[9th apr,2013,12th apr,2013]
    enddate[-----]



    please help how to retrieve this data in table format

  4. #4
    Junior Member
    Join Date
    Apr 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: retrieving hashmap data in table format based key values

    how can we retrieve multimap values from java class to jsp page

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,541
    My Mood
    Hungover
    Thanks
    145
    Thanked 648 Times in 553 Posts

    Default Re: retrieving hashmap data in table format based key values

    You're asking a couple different questions here, and you need to take them one at a time.

    First off, write a program that contains a single function that simply prints out the values of a List in a row (or whatever format you want). Currently you're using the default display, which apparently isn't what you want.

    After you have that working, then think more carefully about what you want to display. Use the function you wrote in step 1 to help you.

    Stop trying to tackle the whole problem at once. Break it down into smaller steps, then work on each step individually.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 0
    Last Post: January 30th, 2013, 10:08 PM
  2. [SOLVED] Get a new key in HashMap with values of another key.
    By Purple01 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: September 21st, 2012, 05:33 AM
  3. retrieve data from database using Hashmap (multiple values in one key)
    By ashin12 in forum Collections and Generics
    Replies: 2
    Last Post: April 4th, 2012, 06:22 AM
  4. check duplicate key and value in hashmap
    By starmandell in forum Algorithms & Recursion
    Replies: 1
    Last Post: February 9th, 2011, 04:25 PM