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 3 of 3

Thread: Setting Up a map using jstl

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Setting Up a map using jstl

    Hi,
    I am facing a problem that i am sure many have faced before , but i myself could not arrive at a solution, hence need your support and advice, friends.

    I have a query which is retreiving two things for me, one is groupcode and other is product name. Now i have to put them in a map as key - value pairs and display the value for a particular key using check boxes in jsp. I have used jstl here, But i am not realising how to go forward with the map and checkbox issue.
    Kindly help, here is my code :
    HTML Code:
    <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jstl/sql_rt" prefix="sql" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
    <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %> 
    <sql:setDataSource driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://10.232.6.26:1433;databasename=uisample" user="iwdbuser" password="iwdbuser"/>
    <html>
    <body>
    <sql:query var = "test1" >
    select  frk_fundGroupCode , frk_productName from document_detail group by frk_fundGroupCode,frk_productName;
    </sql:query>
    <table border="0">
    <c:forEach var="row" items="${test1.rows}">
    <tr>
    <td><input type="checkbox" name="id" value="">
    <c:forEach var = "key" items ="${row.frk_fundGroupCode}" >
    <c:out value="${key}"/>
    <tr><td><input type="checkbox" name="id" value=""><c:out value = "${row.frk_productName}"/></td></tr>
    </c:forEach>
    </td>
    <c:set var="count" value="${count + 1 }"></c:set>
    </tr>
    </c:forEach>
    <input type="checkbox" name="id" value="number"><strong> Showing <c:out value = "${count}"/> Funds</strong>  for KIID Documents. 
    </table>
    </body>
    </html>
    currently i am getting the result as (consider []--->checkbox)
    Showing 4 Funds for KIID Documents.
    []FTF
    []Franklin Templeton Strategic Dynamic Fund
    []FTF
    []Templeton UK Equity Fund
    []FTSAF
    []Franklin Mutual Shares Fund
    []FTSAF
    []Templeton Global Emerging Markets Fund

    However, considering FTF as groupcode and key it has two values -->Franklin Templeton Strategic Dynamic Fund,Templeton UK Equity Fund.
    So what i want is like :
    []FTF
    []Franklin Templeton Strategic Dynamic Fund
    []Templeton UK Equity Fund
    []FTSAF
    []Franklin Mutual Shares Fund
    []Templeton Global Emerging Markets Fund

    Kindly tell me how to achieve this.


  2. #2
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: Setting Up a map using jstl

    So your map isn't a map of a string onto another string, it's a map of string onto a list of strings? I'm sure there's a clue in there somewhere.

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Setting Up a map using jstl

    @Sean4u : Yes you are quite right.
    The Keys are Strings which in turn will , each of them map to a list of values. And the problem is , i am not realizing how to construct a map using the keys like group code and product name obtained from a sql query using jstl in jsp.
    Hence, need some big advice here on how to do that.

Similar Threads

  1. jstl talk mysql iterration problem reg
    By Edde in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: September 1st, 2011, 03:53 AM
  2. [SOLVED] How to use JSTL 1.1 in NetBeans 7?
    By Lord Voldemort in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: July 15th, 2011, 01:11 PM
  3. Confused about setting up JSP
    By mjpam in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: September 17th, 2010, 05:14 AM
  4. Setting up, using DataSources
    By jasonm in forum JDBC & Databases
    Replies: 1
    Last Post: March 4th, 2010, 10:37 PM
  5. setting the compiler for eclipse mac os x
    By etidd in forum Java IDEs
    Replies: 2
    Last Post: January 29th, 2010, 10:18 AM