If statement in jstl

I am new to jstl and I wrote the code for editing the information and i want the visible checkbox is checked if in the database it is visible or not checked in the checkbox if it is invisible but not working help me guys
<div>
<span class="label">Visible:</span>
<input type="checkbox" name="visible"
<c:if test="${ad.visible}">value="checked" </c:if>>
</div>

http://www.w3schools.com/tags/tag_input.asp
  <input type="checkbox" name="visible"
    <c:if test="${ad.visible}">checked="checked" </c:if>>

Similar Messages

  • Two if condition in JSTL

    can I use and in if statement in JSTL, I f I want to change the following code to JSTL , what should I do
    if (!(Tassistant.equals("on"))&&         (!TassistantStart.equals("dd/mm/yyyy"))&&         (!TassistantUntill.equals("dd/mm/yyyy")))
    do I have to use ? can I use and to connection then I don't need that much close </c:if>
    <c:if test="${found.tassistant!='on'}"> }<c:if test="${found.tassistant!='dd/mm/yyyy'}"> </c:if>               </c:if>
    Thnak you!

    You can just use the same operators in EL.
    And in the future, please choose forum carefully. Posting a very simple question at a wrong forum doesn't let you overcome as smart.

  • Example web.xml for JSTL?

    I need to find an example web.xml file that shows where thet tablib statements for JSTL go and what they look like in a web.xml file. I was looking at an article I found through Google that pointed to Javasoft doc on this subject but the link didn't work, and anyway, I prefer examples to specifications. I haven't found a good example yet. Can someone point me to one or post one? I need both contents of the taglib statements and a clear picture of exactly where in the web.xml file they go. I think the statements are:
    <taglib>
        <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
        <taglib-location>/WEB-INF/fmt.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
        <taglib-location>/WEB-INF/c.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
        <taglib-location>/WEB-INF/sql.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
        <taglib-location>/WEB-INF/x.tld</taglib-location>
      </taglib>Thanks.
    Ken

    Just to confirm
    - what server/version are you deploying on where it doesn't work?
    - what server do you have that it does work on? Is it the same?
    - you have both standard.jar and jstl.jar? Check the version by opening with a zip tool and looking at the manifest.mf file.
    - what URI are you using to import the tag libraries with?
    To install JSTL, all you need is jstl.jar and standard.jar, in a place where the webapp can find them.
    Most commonly is the WEB-INF/lib directory
    Most servers also have a "shared" directory idea - eg tomcat has the /common/lib and /shared/lib directories. The JSTL jars will work just as well in those directories.

  • Using union command in jsp

    i have my select statement in my jsp like this....
    <sql:query dataSource="${conn}" var="kur">
    select ka_kod_sesi_semester sem,
    ka_kod_kursus kursus,
    BK_NAMA_KURSUS nama_kursus
    from akd.kursus_ambil,
    akd.bank_kursus,
    akd.pelajar
    where ka_no_matrik=pel_no_matrik
    and pel_no_matrik=?
    and ka_kod_kursus=bk_kod_kursus
    union
    select kur_sej.ka_kod_sesi_semester sem,
    kur_sej.ka_kod_kursus kursus,
    BK_NAMA_KURSUS nama_kursus
    from akd.kursus_ambil_sejarah kur_sej,
    akd.bank_kursus,
    akd.pelajar
    where kur_sej.ka_no_matrik=pel_no_matrik
    and pel_no_matrik=?
    and kur_sej.ka_kod_kursus=bk_kod_kursus
    order by ka_kod_sesi_semester,
    ka_kod_kursus
    <sql:param value="${param.ID}"/>
    <%-- <sql:param value="${param.ID}"/> --%>
    </sql:query>
    <%--
    Create an KursusBean and save it in
    the session scope and redirect to the appropriate page.
    --%>
    <c:set var="kurValues" value="${kur.rows[0]}"/>
    <jsp:useBean id="kurPel" scope="session" class="beans.pelajar.KursusBean">
    <c:set target="${kurPel}" property="sem" value="${kurValues.sem}"/>
    <c:set target="${kurPel}" property="kursus" value="${kurValues.kursus}"/>
    <c:set target="${kurPel}" property="namaKursus" value="${kurValues.nama_kursus}"/>
    </jsp:useBean>
    but when i runnig this page, i will get this error...
    : ORA-00904: "KA_KOD_SESI_SEMESTER": invalid identifier
    i'm using oracle 9i database....
    which the best method
    1) select statement in java bean
    2) select statement in jstl
    pls...help me

    The cause of the ORA-00904 is "The column name entered is either missing or invalid". Check your SQL queries and see if all your column names are correct.
    HTH

  • Jslt +sql count

    Hi,
    i would be thanksfull fi anyone would tell me, how to get the value from the count sql-statement using jstl..
    the tags should look sth like this:
    <sql:query var="getUser" >
    SELECT COUNT(Row) FROM table
    </sql:query>
    <c:set var="count" value="${getUser}" scope="page" />
    but sth is wrong. for any suggestion thanks!

    ive solve this in that way..
    <sql:query var="getUser" >
    SELECT COUNT(Row) AS cnt FROM table
    </sql:query>
    <c:forEach var="Temp" begin="0" end="1" items="${getUser.rows}">
    <c:set var="users" value="${Temp.cnt}" scope="session" />
    </c:forEach>
    but if there is any way to set the variable users in some way with using only one tag?

  • Standard.jar taglib is malformed

    Hi
    I have the following warnings on the console.
    I have bea weblogic 8.1 SP6
    The application works perfect, but I keep getting this warnings.
    Is there a way to fix this? or at least to hide only these warnings?
    Thanks
    Daniel
    ####<Dec 4, 2007 10:19:42 AM EST> <Warning> <HTTP> <DV2KATUS03> <ATUS01sp4> <main> <<WLS Kernel>> <> <BEA-101248> <[ServletContext(id=11572001,name=webdesktop,context-path=/)]: Deployment descriptor "jar:file:E:\public\AppServer\ATUSDEVsp4\ATUS01sp4\.wlnotdelete\extract\ATUS01sp4_webdesktop_webdesktop\jarfiles\WEB-INF\lib\standard-1.1.2.jar!/standard-1.1.2/META-INF/fn.tld" is malformed. Check against the DTD: cvc-elt.1: Cannot find the declaration of element 'taglib'. (line 6, column 17).>
    ####<Dec 4, 2007 10:19:42 AM EST> <Warning> <HTTP> <DV2KATUS03> <ATUS01sp4> <main> <<WLS Kernel>> <> <BEA-101248> <[ServletContext(id=11572001,name=webdesktop,context-path=/)]: Deployment descriptor "jar:file:E:\public\AppServer\ATUSDEVsp4\ATUS01sp4\.wlnotdelete\extract\ATUS01sp4_webdesktop_webdesktop\jarfiles\WEB-INF\lib\webdesktop_taglib-1.0.jar!/META-INF/webdesktopTag.tld" is malformed. Check against the DTD: cvc-elt.1: Cannot find the declaration of element 'taglib'. (line 3, column 81).>
    ####<Dec 4, 2007 10:19:42 AM EST> <Warning> <HTTP> <DV2KATUS03> <ATUS01sp4> <main> <<WLS Kernel>> <> <BEA-101248> <[ServletContext(id=11572001,name=webdesktop,context-path=/)]: Deployment descriptor "jar:file:E:\public\AppServer\ATUSDEVsp4\ATUS01sp4\.wlnotdelete\extract\ATUS01sp4_webdesktop_webdesktop\jarfiles\WEB-INF\lib\standard-1.1.2.jar!/standard-1.1.2/META-INF/x.tld" is malformed. Check against the DTD: cvc-elt.1: Cannot find the declaration of element 'taglib'. (line 6, column 19).>
    ####<Dec 4, 2007 10:19:42 AM EST> <Warning> <HTTP> <DV2KATUS03> <ATUS01sp4> <main> <<WLS Kernel>> <> <BEA-101248> <[ServletContext(id=11572001,name=webdesktop,context-path=/)]: Deployment descriptor "jar:file:E:\public\AppServer\ATUSDEVsp4\ATUS01sp4\.wlnotdelete\extract\ATUS01sp4_webdesktop_webdesktop\jarfiles\WEB-INF\lib\standard-1.1.2.jar!/standard-1.1.2/META-INF/permittedTaglibs.tld" is malformed. Check against the DTD: cvc-elt.1: Cannot find the declaration of element 'taglib'. (line 6, column 19).>
    ####<Dec 4, 2007 10:19:42 AM EST> <Warning> <HTTP> <DV2KATUS03> <ATUS01sp4> <main> <<WLS Kernel>> <> <BEA-101248> <[ServletContext(id=11572001,name=webdesktop,context-path=/)]: Deployment descriptor "jar:file:E:\public\AppServer\ATUSDEVsp4\ATUS01sp4\.wlnotdelete\extract\ATUS01sp4_webdesktop_webdesktop\jarfiles\WEB-INF\lib\standard-1.1.2.jar!/standard-1.1.2/META-INF/c.tld" is malformed. Check against the DTD: cvc-elt.1: Cannot find the declaration of element 'taglib'. (line 6, column 19).>
    ####<Dec 4, 2007 10:19:42 AM EST> <Warning> <HTTP> <DV2KATUS03> <ATUS01sp4> <main> <<WLS Kernel>> <> <BEA-101248> <[ServletContext(id=11572001,name=webdesktop,context-path=/)]: Deployment descriptor "jar:file:E:\public\AppServer\ATUSDEVsp4\ATUS01sp4\.wlnotdelete\extract\ATUS01sp4_webdesktop_webdesktop\jarfiles\WEB-INF\lib\standard-1.1.2.jar!/standard-1.1.2/META-INF/sql.tld" is malformed. Check against the DTD: cvc-elt.1: Cannot find the declaration of element 'taglib'. (line 6, column 19).>
    ####<Dec 4, 2007 10:19:42 AM EST> <Warning> <HTTP> <DV2KATUS03> <ATUS01sp4> <main> <<WLS Kernel>> <> <BEA-101248> <[ServletContext(id=11572001,name=webdesktop,context-path=/)]: Deployment descriptor "jar:file:E:\public\AppServer\ATUSDEVsp4\ATUS01sp4\.wlnotdelete\extract\ATUS01sp4_webdesktop_webdesktop\jarfiles\WEB-INF\lib\standard-1.1.2.jar!/standard-1.1.2/META-INF/scriptfree.tld" is malformed. Check against the DTD: cvc-elt.1: Cannot find the declaration of element 'taglib'. (line 6, column 19).>
    ####<Dec 4, 2007 10:19:43 AM EST> <Warning> <HTTP> <DV2KATUS03> <ATUS01sp4> <main> <<WLS Kernel>> <> <BEA-101248> <[ServletContext(id=11572001,name=webdesktop,context-path=/)]: Deployment descriptor "jar:file:E:\public\AppServer\ATUSDEVsp4\ATUS01sp4\.wlnotdelete\extract\ATUS01sp4_webdesktop_webdesktop\jarfiles\WEB-INF\lib\standard-1.1.2.jar!/standard-1.1.2/META-INF/fmt.tld" is malformed. Check against the DTD: cvc-elt.1: Cannot find the declaration of element 'taglib'. (line 6, column 19).>
    -------------------------------------------------------------------------------------

    There is no way to hide these warnings. The main reason with these warnings is that standard-1.1.2.jar is based on JSP 2.0 where as WLS 8.1 SP6 does not support JSP 2.0, but only JSP 1.2. Please check http://e-docs.bea.com/wls/docs81/notes/new.html#1184292.
    In order to resolve the issue, either you need to use JSTL supported with JSP 1.2 or need to upgrade to WLS versions 9.x or higher.
    Please check http://java.sun.com/products/jsp/jstl/, which states
    JSTL 1.1 Specification Maintenance Release This release builds on JSTL 1.0, adding a function library and requiring a Web container that supports JSP 2.0.
    Jakarta TagLibs Project also states that JSTL 1.1 requires a JSP container that supports JSP 2.0 Specifications. Please see http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html.

  • JSTL JOIN STATEMENT

    Dear Sirs,
    I have the below JSTL code.
    <sql:query var="books" dataSource="${dataSource}">
    SELECT ENG_BOOKS.CODE FROM ENG_BOOKS, FR_BOOKS
    WHERE ENG_BOOKS.CODE = FR_BOOKS.CODE
    </sql:query>
    <table>
    <c:forEach var="row" items="${books.rows}">
    <tr>
    <td><c:out value="${row.ENG_BOOKS.CODE }"/></td>
    </tr>
    </c:forEach>
    </table>
    Putting the colums retreived from the above select statement in
    <c:out value="${row.ENG_BOOKS.CODE }"/>
    gives an error.
    Please help

    You're using the table name to retrieve the value. This is not going to work. Use column names only or introduce a column alias.
    Having said that, you should not be placing any business logic in JSP files and certainly not any database logic. The JSTL SQL taglib should only be used for quick tests. At least refactor that code to a DAO class, write a Servlet which gets the data from the DAO class and sets it as request attribute and finally let the JSTL c:forEach access it.

  • JSTL when statement

    What is the syntax for multiple values in a when statement ?

    All the conditions are considered one 'Expression' since they yeild one result. As such they should all be in the same ${ } deliminator:
    <c:when test="${a == b and c != d }">

  • JSTL: Work with conditional statements

    Hallo everybody!
    I'd have the following question:
    If I need to have a condition whithin my JSP, I can write, e.g.:
    <c:if test="${pageContext.request.method=='POST'}">Here I access some class variable, it is clear.
    But what if a condition concerns a result of a method call on an object? E.g., I need to check if pageConfig.isReadonly("commodity_group") is true or false?
    Obvously, <c:if test="${pageConfig.isReadonly("commodity_group")}"> does not work.
    I can't find a way to do it...
    Andrew

    There isn't a direct way in EL. EL can only call getters/setters.
    It can not call any bean methods that take parameters
    You can hack it a little if your pageConfig bean has two attributes instead of one.
    public class PageConfig{
      String field;
      public String getField(){return field;}
      public void setField(String field){this.field = field;}
      public boolean isReadOnly(){ return isReadOnly(field) }
      public boolean isReadOnly(String field){
        //your implementation
    }And then
    <c:set target="pageConfig" property="field" value="commodity_group"/>
    <c:if test="${pageConfig.readOnly}">
    </c:if>An alternative in an EL container is to use a custom function.

  • Accessing JSTL values from JSP

    I've run into a problem I'm not sure has a solution. Could be bad design on my part, or just a poor imagination. If this has been answered previously, please point me to the post.
    I am using some JSTL to do a SQL query and displaying the records in a select box:
    <sql:query var="aResults" sql="select * from TYPE_STATE_LIST where tslAllowable=1" />                           
    <c:forEach var="oRecord" items="${aResults.rows}">                               
      <option value="<c:out value="${oRecord.tslID}" />"><c:out value="${oRecord.tslFullName}" /></option>                                   
    </c:forEach>I want to be able to reset their selection to the value they entered when the form is refreshed, though. I'm trying to figure out how to grab the oRecord value from the JSTL and use it in a JSP IF statement:
    <% if( oRecord.tslID==request.getParameter("state") ) { %>
      <option selected value="<c:out value="${oRecord.tslID}" />"><c:out value="${oRecord.tslFullName}" /></option> 
    <% } else { %>
      <option value="<c:out value="${oRecord.tslID}" />"><c:out value="${oRecord.tslFullName}" /></option> 
    <% } %>I thought about using the JSTL <c:choose> tag instead, but then how would I access the previous value with request.getParameter()?
    Any suggestions?

    ${param.state}It's better if you place the sql query into a class rather than display it in the jsp, it's more flexible and programmable.

  • Calendar in JSTL

    Hi ,
    I am using JSTL in JSP and there is an If statement which says
    if (Calendar.get(Calendar.YEAR)!=2000){
    do some thing
    I need to know how to write that if condition in JSTL.
    J4v4Guru.

    j4v4guru wrote:
    Hi ,
    I am using JSTL in JSP and there is an If statement which says
    if (Calendar.get(Calendar.YEAR)!=2000){
    do some thing
    I need to know how to write that if condition in JSTL.
    J4v4Guru.no JSTL docs available to you? think about <c:if> tag.
    %

  • If statement inconsistency?

    Yay! Another post from me!
    I've got an if statement in a bean that seems to be processing fine when I create a test java class, but doesn't work fine when the bean is invoked by a jsp.
    My code, let me shows you it:
    First, the test class:
    package com.serco.inquire;
    import java.util.*;
    import java.text.*;
    public class TestCollection {
         public static void main(String[] args) {
              IrCollection myCollection = new IrCollection();
              myCollection.setSort("none");
              myCollection.setMgrid("none");
              int endpoint = myCollection.getSize();
              for (int i=0;i<endpoint;i++) {
                   InquireRecord curRec = myCollection.getCurRecords(i);
                   Long milis = new Long(curRec.getSubmitDate());
                   Date theDate = new Date(milis);
                   Format formatter = new SimpleDateFormat("dd MMM yyyy");
                   String s = formatter.format(theDate);
                   System.out.println("ID: " + curRec.getID() + " | Subject: " + curRec.getSubject());
    }a snippit from the IrCollection class it calls:
    private void processSort(String datum) {
              int LastChar = datum.length()-1;
              String colName = datum.substring(0, LastChar);
              if (datum=="none") {
                   this.fullSort  = " ORDER BY lastUpdated DESC";
              } else {
                   if (datum.endsWith("2")) {
                        this.fullSort = " ORDER BY " + colName + " ASC";
                   } else {
                        this.fullSort = " ORDER BY " + colName + " DESC";
         }There's more code in another method that calls this particular method using: this.processSort(this.sort);But the problem is that if (datum=="none") portion in the second code sample. Given that line 10 of the first class sets the member variable sort to "none", that processSort() method should set the member variable fullSort to " ORDER BY lastUpdated DESC"
    And if I use the class in the first sample, it does that.
    HOWEVER
    I have this custom tag:
    <%@ tag body-content="scriptless" import="com.serco.inquire.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ attribute name="mgr" required="true" %>
    <%@ attribute name="mkind" required="false" %>
    <%@ attribute name="sort" required="false" %>
    <c:if test="${empty mkind}">
      <c:set var="mkind" value="manager" />
    </c:if>
    <c:if test="${empty sort}">
      <c:set var="sort" value="none" />
    </c:if>
    <jsp:useBean id="irc" scope="page" class="com.serco.inquire.IrCollection">
      <jsp:setProperty name="irc" property="mgrtype" value="${mkind}" />
      <jsp:setProperty name="irc" property="sort" value="${sort}" />
      <jsp:setProperty name="irc" property="mgrid" value="${mgr}" />
    </jsp:useBean>
    ${irc.fullsort}Which the .jsp file invokes with this:
    <c:set var="user" value="none" />   
    <c:set var="sort" value="none" />
    <inq:displayCollection>
      <jsp:attribute name="mgr">${user}</jsp:attribute>
      <jsp:attribute name="mkind">cotr</jsp:attribute>
      <jsp:attribute name="sort">${sort}</jsp:attribute>
    </inq:displayCollection>In other words, the exact same data is fed to the IrCollection bean. so I should get the same data, right?
    Except I get this: WHERE cotr = 'none' ORDER BY non DESC so when Java calls it, it thinks "none" == "none"
    but when jsp calls it, it thinks "none" != "none"

    To compare objects' states, including Strings' contents, use equals(), not ==. The == operator tests whether 2 references have the same value, that is, whether both point to the same object (or are both null). The equals() method does whatever that class's implementor tells it to do, but its purpose--and what it does in reasonable implementations--is to compare objects' states. In the case of String, it tests whether both String objects contain equal character sequences.
    If == happened to return true in your test case, its because interning led to both references pointing to the same String object in the constant pool.

  • Jstl c:if test

    I have put a string in my request:
    pageContext.getRequest().setAttribute("photoAccountmanager", "SUCCESS");
    How can I retrieve the string in jstl? The next statement doesn't work:
    <c:if test="${request.photoAccountmanager == 'SUCCESS'}" >
    </c:if>

    The proper EL way of retrieving from a particular scope is to use the Scope's map (requestScope for requests, sessionScope for sessions, applicationScope for application).
    <c:if test="${requestScope.photoAccountmanager == \"SUCCESS\"}">
    Note, that as long as there is no fear of having a variable of the same name in a different scope, specifying the scope is not necessary:
    <c:if test="${photoAccountmanager == \"SUCCESS\"}">
    Also not the escaped double quotes rather than single quotes. Not positive this is necessary, but I think it is the correct way to do it.
    Finally, if trouble still persists, try using
    <c:if test="${requestScope.photoAccountmanager eq \"SUCCESS\"}">

  • Using HashMap's ContainsKey() in JSTL

    Can we use HashMap's containsKey() in JSTL <c:if > statement
    I tried with the sample
    <html:select property="Type" multiple = "true" size = "3">
    <option value='<c:out value="${key}"/>'
    <c:if test="${requestScope.test.containsKey(key)}">
    selected
    </c:if>     
    <c:out value="${value}"/></option>
    </html:select >
    When i executed the above code i encountered JSP Error
    Can any one please let me know the correct code

    You can't call java methods from JSTL. It uses the EL - not java.
    However there is a solution.
    You access maps using the square brackets [ ] notation.
    ie ${test[key]}
    is the same as test.get(key)
    try
    <c:if test="${ not empty test[key] }"/>
    However seeing as you are using the struts tags, doesn't that automatically take care of this for you? Why don't you use the struts tags for the options list as well as the select? Just a thought :-)
    Cheers,
    evnafets

  • 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.

Maybe you are looking for

  • Backspace key broke, replacement? (Satellite L10)

    Cleaning my keys and the backspace key broke. Satellite L10-281 Anyone help me out on how i would go about getting a replacement? Toshiba site useless can't find a single thing.

  • Test Equipment for calibration

    Dear Experts, Is it necessary to create Calibration Orders against Test Equipments only ?? or we can do the same against Machines also?? As in some cases there is preventive & calibration plan against same equipment then if we create Test equipment,,

  • RG1 register update report

    Hi All, We have a new requirement to add the new column for billing document number in RG1update register report ( J1i5).  Any one can please tell me the table name or suggest me where can i get the datas. Than

  • Can anyone explain me in detail about LSMW?:

    Can anyone explain me in detail about LSMW?How the process of migration takes place from Non-sap to SAP in flat files?

  • Sap error for excises

    Dear sir We are giving following 2 cases regarding updation of data in the RG-1 Register : CASE  NO. 1)   In case of  Product Code  : NST0071B041 0.33BFC71 55 .C.S4 R411 having 2 different sales Transactions in the Month of July u2013 2010, Reference