Question | Using JSTL to Display elements of an ArrayList of HashMaps

Hi All,
I would like some advice on the following code snippet which is a representation of my real code. Please see below for the code snippet and the specific questions I have.
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%
// This Object is an ArrayList of HashMaps
MyClassDataBean myDb =  (MyClassDataBean)session.getAttribute("testDataBean");
// Adding myDb to the pageContext so that EL can be used to render components in this Object
pageContext.setAttribute("myDb",myDb);
pageContext.setAttribute("column1",MyConstants.COLUMN1);
pageContext.setAttribute("column2",MyConstants.COLUMN2);
%>
<html>
<head></head>
<body>
     <c:choose>
      <c:when test="${myDb != null}" >
         <c:forEach var="hashMapAsRow" items="${myDb}" varStatus="lineInfo">
          <tr>
              <td><c:out value="${hashMapAsRow[column1]}" /></td>
           <td><c:out value="${hashMapAsRow[column2]}" /></td>
           </tr>
     </c:forEach>
     </c:when>
     <c:otherwise>
     <tr><td colspan="100%">No Data Exists</td></tr>
     </c:otherwise>
   </c:choose>
</body>
</html>Question: Is there an alternative to accessing elements using the core tag library in this Object without using pageContext.setAttribute() ? If not, would the c_rt library be better to use in this scenario? If so, could someone give me an example of the right way to use it based on the above example?
Thanks,
Joe

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<c:set var="myDb"  value="${sessionScope.testDataBean}" />
<html>
<head></head>
<body>
      <c:choose>
       <c:when test="${myDb != null}" >
          <c:forEach var="hashMapAsRow" items="${myDb}" varStatus="lineInfo">
           <tr>
               <td><c:out value="${hashMapAsRow['column1']}" /></td>
             <td><c:out value="${hashMapAsRow['column2']}" /></td>
            </tr>
     </c:forEach>
      </c:when>
      <c:otherwise>
     <tr><td colspan="100%">No Data Exists</td></tr>
      </c:otherwise>
    </c:choose>
</body>
</html> or the one below
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head></head>
<body>
      <c:choose>
       <c:when test="${sessionScope.testDataBean != null}" >
          <c:forEach var="hashMapAsRow" items="${sessionScope.testDataBean}" varStatus="lineInfo">
           <tr>
               <td><c:out value="${hashMapAsRow['column1']}" /></td>
             <td><c:out value="${hashMapAsRow['column2']}" /></td>
            </tr>
     </c:forEach>
      </c:when>
      <c:otherwise>
     <tr><td colspan="100%">No Data Exists</td></tr>
      </c:otherwise>
    </c:choose>
</body>
</html> is this the one which you are looking for ??
REGARDS,
RaHuL

Similar Messages

  • Using JSTL to display space conditionally

    Hi,
    I need to use JSTL to insert a space when the value of a particular variable is null.
    The obvious approach would be to use the following code:
    <c:choose>
    <c:when test="${var} != null">${var}</c:when>
    <c:otherwise> </c:otherwise>
    </c:choose>
    OR
    ${var} <c:if test="$var== null}">  </c:if>
    However, i need to do this in a lot of places ( a number of table cells to be precise) and the above code looks bulky to be inserted everywhere.
    I read the JSTL documentation and found that the following code can also be used:
    <c:out value='${var}' default=" " />
    As per JSTL documetation, the default will be used if the variable has a null value and hence the above code should work theoretically.
    My problem is that whenever the value of the variable is null, the output is   and not a space. i.e. actually the text   is displayed. Is there some way of getting the space to display?
    Or is there any other alternative to condinally insert a space without having to write the bulky <c:choose> OR <c:if> code?
    Thanks in advance.

    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <c:set var="myDb"  value="${sessionScope.testDataBean}" />
    <html>
    <head></head>
    <body>
          <c:choose>
           <c:when test="${myDb != null}" >
              <c:forEach var="hashMapAsRow" items="${myDb}" varStatus="lineInfo">
               <tr>
                   <td><c:out value="${hashMapAsRow['column1']}" /></td>
                 <td><c:out value="${hashMapAsRow['column2']}" /></td>
                </tr>
         </c:forEach>
          </c:when>
          <c:otherwise>
         <tr><td colspan="100%">No Data Exists</td></tr>
          </c:otherwise>
        </c:choose>
    </body>
    </html> or the one below
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <head></head>
    <body>
          <c:choose>
           <c:when test="${sessionScope.testDataBean != null}" >
              <c:forEach var="hashMapAsRow" items="${sessionScope.testDataBean}" varStatus="lineInfo">
               <tr>
                   <td><c:out value="${hashMapAsRow['column1']}" /></td>
                 <td><c:out value="${hashMapAsRow['column2']}" /></td>
                </tr>
         </c:forEach>
          </c:when>
          <c:otherwise>
         <tr><td colspan="100%">No Data Exists</td></tr>
          </c:otherwise>
        </c:choose>
    </body>
    </html> is this the one which you are looking for ??
    REGARDS,
    RaHuL

  • JSP Worked Well Using Scripting Elements, But, Becomes a Null Using JSTL

    I have to bother all of you again with my JSTL problems. I am working on a JSP, which is very similar to the one that caused a lengthy discussion on this forum before. This JSP is a bit more complicated.
    Again, this JSP worked well and displayed what I expected when the page was coded using the scripting elements.
    I tried to use JSTL where possible and managed to correct all the compilation errors.
    Now, I got a simple message: 'null' in the browser without any explanation - typical problem working with JSP: very difficult to debug.
    I have tried to identify problems "one by one" and found the first encounter is where I want to set the background color for each row inside the <c:forEach ....> tag.
    I examined the code again and again, I could not see what would lead to 'null'. I need a hand again.
    <%@ taglib uri="/tags/struts-html-el" prefix="html" %>
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
    <%@ taglib uri="/tags/tiles" prefix="tiles" %>
    <%@ taglib uri="/tags/request" prefix="req" %>
    <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
    <%@ page import="org.apache.artimus.message.utility.ParamUtil" %>
    <%@ page import="org.apache.artimus.message.exceptions.AssertionException" %>
    <%@ page import="org.apache.artimus.authorization.OnlineUser" %>
    <%@ page import="org.apache.artimus.authorization.OnlineUserImpl" %>
    <%@ page import="org.apache.artimus.filter.EnableEmotionFilter" %>
    <%@ page import="org.apache.artimus.message.ThreadBean" %>
    <%@ page import="org.apache.artimus.message.PostBean" %>
    <%@ page import="org.apache.artimus.message.AttachmentBean" %>
    <%@ page import="org.apache.artimus.MessageInboxConfig" %>
    <%@ page import="org.apache.artimus.WebSiteGlobal" %>
    <%@ page import="org.apache.artimus.SiteUtil" %>
    <c:set var="threadBean" value="${requestScope.ThreadBean}" />
    <c:set var="postRows" value="${requestScope.PostBeans}" />
    <c:set var="numberOfPosts" value="${requestScope.NumberOfPosts}" />
    <c:set var="previousTopic" value="${requestScope.PreviousTopic}" />
    <c:set var="nextTopic" value="${requestScope.NextTopic}" />
    <c:set var="offset" value="${requestScope.offset}" />
    <c:set var="threadID_int" value="${requestScope.thread}" />
    <c:if test="${threadBean.threadID != threadID_int}">
        The two threadID are not the same.
    </c:if>
    <c:set var="threadID" value="${threadID_int}" />
    <%-- the code before this line works fine and I have a number of things displayed as expected --%>
    <c:forEach var="postBean" items="{postRows}" varStatus="i">
    <% PostBean postBean =
       ( PostBean )pageContext.getAttribute( "postBean" );
    %>
       <c:choose>
          <c:when test="${(postBean.parentPostID) eq 0}">
             <c:set var="background" value="#FFCE9C" />
          </c:when>
          <c:otherwise>
             <c:choose>
                <c:when test="${(i+1)%2 ne 0}">
                   <c:set var="background" value="#EEEEEE" />
                </c:when>
                <c:otherwise>
                   <c:set var="background" value="#FFFFFF" />   
                </c:otherwise>
             </c:choose>
          </c:otherwise>
       </c:choose>
    <table width="95%" border="0" cellspacing="1" cellpadding="5" align="center" bgcolor="#999999">
      <tr bgColor="${background}">
      </tr>
    </table>
    </c:forEach>

    Where is the null occuring? Have you looked at the returned HTML code to see where the 'null' is?
    You might try just a few <c:out value=""/>, like:
    The postRows = <c:out value="${postRows"/><br/>
    <c:forEach var="postBean" items="${postRows"/>
      The Current postBean = <c:out value="${postBean}"/><br/>
      The Current parentPostID = <c:out value="${postBean.parentPostID eq 0}"/><br/>
      <!-- Only do this set if background ends up null, to make sure the scope of background is wide enough -->
      <c:set var="background" value="#FFFFFF"/>
      <c:choose>
        <c:when test="${postBean.parentPostID eq 0}">
          <c:set var="background" value="#FFCE9C"/>
        </c:when>
        <c:when test="${(i+1)%2 ne 0}">
          <c:set var="background" value="#EEEEEE"/>
        </c:when>
        <c:otherwise>
          <c:set var="background" value="#FFFFFF"/>
        </c:otherwise>
      </c:choose>
      The Background is now = <c:out value="${background}"/><br/>
      <table width="95%" border="0" cellspacing="1" cellpadding="5" align="center" bgcolor="#999999">
        <tr bgColor="${background}">
        </tr>
      </table>
    </c:forEach>By adding output like that when we are debugging we can help track down where problems that occur are coming from. That and looking at the source code have been invaluable to me...

  • When using Adobe Photoshop Elements, is it legal to use shapes etc. (displayed in 'Artwork and Effects') when creating a product to be sold? Thank you.

    When using Adobe Photoshop Elements, is it legal to use shapes etc. (displayed in 'Artwork and Effects') when creating a product to be sold? Thank you.

    Thank you very much for answering my question. Have a great day.

  • How to send object arraylist from servlet to jsp and display using jstl

    Hi All....
    I have a simple application and problem with it.
    Once user logged in to system the user will redirect to LoginServlet.java controller.
    Then in LoginServlet I want to redirect user to another page called book_details.jsp.
    this is my login servlet.
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              PrintWriter out = response.getWriter();
              ArrayList<BankAccountDTO> account_list = new ArrayList();
              ResultSet resultSet = null;
              LowFairAirDB airDB = null;
              try{
                   airDB = new LowFairAirDB();
                   String query = "SELECT account_id, type, description, balance, credit_line, begin_balance, begin_balance_time_stamp FROM bank_account";
                   airDB.sqlSelect(query);
                   resultSet = airDB.getResultSet();
                   while(resultSet.next()){
                        account_list.add(new BankAccountDTO(resultSet.getInt(1),
                                                                     resultSet.getInt(4),
                                                                     resultSet.getInt(5),
                                                                     resultSet.getInt(6),
                                                                     resultSet.getString(2),
                                                                     resultSet.getString(3),
                                                                     resultSet.getString(7)));
              }catch(Exception ex){
              }finally{
                   try{resultSet.close();}catch(Exception ex){}
                   airDB.sqlClose();
         }I set bank account values to BankAccountDTO.java objects and add them to the arrayList.
    Next I want to send this objects arrayList to books_details.jsp and wanna display each objects values using JSTL.
    I still finding a way to go through this.
    1. Can anyone say how can I do it?
    2. Is there any other method to do the same thing without using JSTL?
    thanks in advance,
    Dil.

    Naishe wrote:
    In your servlet,
    request.setAttribute("account_list", account_list);
    requestDispatcher.findForward("/your/display/jsp");
    Good. I would only follow the Java naming conventions. E.g. accountList or accounts instead of the ugly PHP/C conventions.
    In the JSP,
    lst = (List< BankAccountDTO >)request.setAttribute("account_list");
    for(BankAccountDTO b: lst){
    populate your HTML tags or whatever
    Wrong. 1) You need getAttribute() and 2) you should not use scriptlets. Use JSTL c:forEach, e.g.<table>
        <c:forEach items="${accounts}" var="account">
            <tr>
                <td>${account.id}</td>
                <td>${account.type}</td>
                <td>${account.description}</td>
            </tr>
        </c:forEach>
    </table>To the topicstarter: for future JSP/JSTL related questions please use JSP/JSTL forum.
    Here it is: [http://forums.sun.com/forum.jspa?forumID=45].

  • How can i display the values in the vector in a jsp using jstl

    in a task i am recieving a vector in a jsp... how can i display those vector values in the jsp using jstl.... plz help me
    thanks in advance

    <%
    here you got vector say; v
    pagecontext.setAttribute("varname",v);
    %>
    <c:forEach var="i" items="${varname}">
    <c:out value="${i}">
    </c:forEach>

  • Displaying a set of records using jstl

    hi i am new to jstl.my requirement is i want to display a set of records from my database using jstl.for eg i want to display 50 records per page and i want to navigate to other records using next and prevoius buttons and i need to put view and edit buttons in that page.can anybody give me a solution for this.urgent

    You may try the paging taglib ...
    http://www.servletsuite.com/servlets/pagertag.htm

  • How to display table data without  using ALV  and table element.

    Hi,
            Its possible to display table data without using ALV  and table element.
           Every time i am fetching data based on (customer,status) fields and displaying these data in my output using alv
           (every time i am fetching single row data ),
           But problem is alv occupying more space in the output , i want to display data part only i dont want field names,
           settings and header data etc..things.
          Give solution to  display data part..
    Regards,
    Rakhi.

    Hi,
    Does you mean that you need ALV without default Function Toolbar...? If this is the case, the easy solution would have been to use Table Element rather. But, if you need to use ALV only without Function Toolbar, you can do away with that as well.
    In that case, after calling GET_MODEL, you need to add few more lines of codes to achieve your goal. Those lines are --
      DATA LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
        LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL(
    * Standard Filter Function setting to FALSE
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_SORT_COMPLEX_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_FILTER_COMPLEX_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_FILTER_FILTERLINE_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_DISPLAY_SETTINGS_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_VIEW_LIST_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_SORT_HEADERCLICK_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_HIERARCHY_ALLOWED( ABAP_FALSE ).
    * Standard Filter Function setting to FALSE Ends
    Here as you can easily notice that LV_VALUE is instantiated on CL_SALV_WD_CONFIG_TABLE. Now, using this LV_VALUE, you set standard functions as False to dis-allow their display.
    Hope this answers your query.
    Thanks.
    Kumar Saurav.

  • Hi Everyone,  I am using iPhone5, my question in how to display name and contact number both stored for incoming and outgoing calls? If I have saved five different numbers with a same name, how do I recognise that from which number caller is calling?

    Hi Everyone,  I am using iPhone5, my question in how to display name and contact number both stored for incoming and outgoing calls? If I have saved five different numbers with a same name, how do I recognise that from which number caller is calling?

    I have friends all over Europe, does it matter what number they use to call me? Nope! All incoming calls are free for me.
    The only time you ever have to worry about which number is if you get charged for incoming domestic/international calls.
    You can tag their number (work/home/iphone) and that may show on the CallerID accordingly.
    It should show, John Doe
    underneath,    work/home/mobile
    For example:
    http://shawnblanc.net/images/img-0009-1.png

  • Question when using the Mini Display Port.

    Hello,
    I just got my 27" Imac, and I was wondering what is the hotkey to switch between the mini display port and the normal desktop?
    Am using a Mini Display to DVI adapter and I can't figure out how to switch between the video sources. Am trying to run my Ps3 off from my mac, any help on what the hotkey is would be wonderful.
    I read some place that command+F2 is the hotkey used to switch between the port, but maybe you have to assign the hotkeys?
    There have been people who have been able to use there systems this way, and Apple states the port is there for this purpose; Any light on this subject would be nice.

    Welcome to the Apple Discussions!
    You can only run your PS3 on the iMac's display if you have an adapter that turns the PS3's video signal into DisplayPort signaling. A mini-DisplayPort to DVI adapter is the wrong adapter to use. That adapter works in only one direction, from a device with m-DP output to a device with DVI input.
    If your PS3 has DVI output then you need an adapter to convert the DVI to HDMI. Then you need a converter to convert the HDMI to m-DP. They run US$149.00. The best resolution that you can expect is 720p.
    http://www.kanexlive.com/products/kanexXD.aspx
    Then you can toggle using Command+F2.
    Dah•veed

  • Re: [iPlanet-JATO] Re: using begin childName Display method

    Steve,
    It sounds like you have your display fields in a container view, and
    that container view is inside of a view bean. I haven't tested whether
    the fireChildDisplayEvents has a "deep" effect on its container view
    children. Meaning that you may have to set fireChildDisplayEvents="true"
    for the <jato:containerView> tag instead. If all else fails and you need
    to just get it working, you can set the fireDisplayEvents="true" for
    each display field tag separately.
    craig
    stephen_winer wrote:
    I should clarify my earlier statement. The data I want to display is
    coming from a model (tied in in the createChild method). I want to
    conditionally reformat the text that is being substituted in the JSP
    for a JATO form element, but I want this to happen on the server, not
    with JavaScript. The begin<childName>Display and
    end<childName>Display methods allow me to do this, in theory, but I
    can not get them to execute.
    Steve
    --- In iPlanet-JATO@y..., Belinda Garcia <belinda.garcia@s...> wrote:
    I don't currently use a begin or end Display method. I merely bind
    the fields to
    the model when the child is created and use the setValue to
    initially set the
    value to what's in the model. I get nulls though if I try to use a
    tiled View. I
    haven't quite got this figured out.
    Belinda
    X-eGroups-Return:
    sentto-2343287-1135-1008613974-belinda.garcia=sun.com@r...
    X-Sender: stephen_winer@y...
    User-Agent: eGroups-EW/0.82
    From: "stephen_winer" <stephen_winer@y...>
    X-Originating-IP: 155.188.191.4
    X-Yahoo-Profile: stephen_winer
    Mailing-List: list iPlanet-JATO@y...; contact
    iPlanet-JATO-owner@y...
    Date: Mon, 17 Dec 2001 18:32:48 -0000
    Subject: [iPlanet-JATO] using begin<childName>Display method
    Content-Transfer-Encoding: 7bit
    I want to be able to conditionally show/hide data as well as
    format
    it for display without touching the model. I found the
    begin<childName>Display and end<childName>Display methods that
    provide the hooks to do this, but I have been unsuccessful in
    getting
    these method to execute. I added the
    fireChildDisplayEvents="true"
    attribute to the jato:useViewBean tag, but this has not helped.
    I
    also added some debug to the ContainerViewBase class in the
    public
    boolean beginChildDisplay(ChildDisplayEvent event) method to see
    what
    was happening. The displayMethodMap was returning null for the
    child
    display methods that were in the view bean. I covered all the
    bases
    (compiling, redeploying, etc.) and nothing has worked. Is there
    anything I am missing or is there some working example of this?
    Steve
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    >For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp

    The hidden field was present in the page, but it looked like this:
    <input type="hidden" name="jato.defaultCommand" value=""../search"">
    Seems like there is a small bug in the code generating this tag.
    FYI - I am using JATO1.2
    What file displays this text? Maybe I can go in and fix it and rejar
    it.
    Steve
    --- Mike Frisino wrote:
    Steve,
    Can you check the HTML source that shows up in the browser? Do you see an entry that looks like this at the bottom of the form in
    question?
    >
    <input type="hidden" name="jato.defaultCommand" value="/search">
    To answer your question - it should work as you described. Some of the JatoSample make use of the defaultCommandChild. Can you try
    running the sample BasicSample->Field Types and let us know what you
    see.
    >
    Failing this you can send me your jsp file , maybe there is some subtle issue there. michael.frisino@s...
    >
    >
    ----- Original Message -----
    From: stephen_winer
    Sent: Friday, December 07, 2001 8:05 AM
    Subject: [iPlanet-JATO] Using the defaultCommandChild in a form
    I am trying to set the defaultCommandChild in my jato:form tag to be
    the searcg button. The search button definition is:
    <jato:button name="search"/>.
    The form tag definition is:
    <jato:form name="PendingIA" defaultCommandChild="/search">
    Clicking on the search button works fine, but hitting return in one
    of the textFields (which submits the form) passes a value of "" to
    the createChild method in my viewBean, which throws an error. Why
    does this not just work as normal and trigger the handleSearchRequest
    () method?
    Steve
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    Service.
    >
    >
    >
    [Non-text portions of this message have been removed]

  • "javax.servlet.jsp.JspException: null" When trying to use JSTL

    Hello,
    I am trying to use some taglibs from Apache but I am getting the following error when trying to access the relevant page:
    org.apache.jasper.JasperException: javax.servlet.jsp.JspException: null
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    org.apache.jasper.JasperException: javax.servlet.jsp.JspException: null
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         org.apache.jsp.Questions_jsp._jspService(Questions_jsp.java:42)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    javax.servlet.ServletException: javax.servlet.jsp.JspException: null
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:854)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
         org.apache.jsp.WEB_002dINF.EL_005f2_jsp._jspService(EL_005f2_jsp.java:171)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         org.apache.jsp.Questions_jsp._jspService(Questions_jsp.java:42)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.reflect.InvocationTargetException
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:597)
         org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(Unknown Source)
         org.apache.jsp.WEB_002dINF.EL_005f2_jsp._jspx_meth_c_set_0(EL_005f2_jsp.java:208)
         org.apache.jsp.WEB_002dINF.EL_005f2_jsp._jspService(EL_005f2_jsp.java:113)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         org.apache.jsp.Questions_jsp._jspService(Questions_jsp.java:42)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)My web.xml file is as follows:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
    version="2.4">
    <display-name>Jsp_Ex09 - JSP Standard Tag Library</display-name>
    <welcome-file-list>
    <welcome-file>welcome.jsp</welcome-file>
    </welcome-file-list>
    <jsp-config>
    <taglib>
    <taglib-uri>/simplequestions</taglib-uri>
    <taglib-location>/WEB-INF/tlds/simplefaq.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/tlds/c.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/tlds/fmt.tld</taglib-location>
    </taglib>
    <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <el-ignored>false</el-ignored>
    <scripting-invalid>true</scripting-invalid>
    </jsp-property-group>
    </jsp-config>
    </web-app>I have the standard and jstl jars in my lib directory and the relevant tlds files int the tlds directory. I am using Tomcat 5.5 and J2EE 5.
    The jsp in question is as follows:
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
    <html>
    <head>
    <title>JSTL Q2</title>
    </head>
    <body>
    <h1>JSTL Question 2</h1>
    <h2>How do I use the JSTL?</h2>
    <jsp:useBean id="questions" class="com.apress.faq.Questions"
    scope="page">
    <jsp:setProperty name="questions" property="topic" value="EL"/>
    </jsp:useBean>
    <table border="1">
    <!-- the literal JSTL tag will be in left column of table -->
    <!-- the evaluated JSTL tag will be in right column of table -->
    <tr><th>tag</th><th>result</th></tr>
    <!-- this tag uses c:out to send the value of an EL to the response -->
    <tr><td><c:out value="${'${'}questions.topic}"/></td>
    <td><c:out value="${questions.topic}"/></td>
    </tr>
    <!-- this tag uses c:set to set the property of a JavaBean -->
    <c:set target="${questions}" property="topic" value="JSTL" />
    <tr>
    <td><c:set target="${'${'}questions}" property="topic"
    value="JSTL"/>
    </td>
    <td><c:out value="${questions.topic}"/></td>
    </tr>
    <!-- this tag uses c:if to determine whether to create another row -->
    <c:if test="${questions.topic == 'EL'}">
    <tr><td>This row will not be created</td>
    <td></td>
    </tr>
    </c:if>
    <c:if test="${questions.topic == 'JSTL'}">
    <tr><td>This row was created because the c:if tag result was true</td>
    <td></td>
    </tr>
    </c:if>
    </table>
    <h2>Multiplication table, 1 - 5</h2>
    <!-use the forEach tag to create a table -->
    <table border="1">
    <tr><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>
    <c:forEach var="i" begin="1" end="5">
    <tr><td><c:out value="${i}"/></td>
    <c:forEach var="j" begin="1" end="5">
    <td><c:out value="${i*j}"/></td>
    </c:forEach>
    </tr>
    </c:forEach>
    </table>
    <h2>Formatting numbers</h2
    <br><fmt:formatNumber value="23.456" type="number" /> results in
    <fmt:formatNumber value="23.456" type="number" />
    <br><fmt:formatNumber type="currency">23.456
    </fmt:formatNumber> results in <fmt:formatNumber
    type="currency">23.456</fmt:formatNumber>
    <br><fmt:formatNumber value=".23456" type="percent"/> results
    in <fmt:formatNumber value=".23456" type="percent"/>
    <br><fmt:formatNumber value=".23456" type="percent"
    minFractionDigits="2"/> results in <fmt:formatNumber
    value=".23456" type="percent" minFractionDigits="2"/>
    </body>
    </html>Can anyone spot the problem?
    Sorry for such a big post!

    ava.lang.reflect.InvocationTargetException
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:597)
         org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(Unknown Source)From the stacktrace, it appears to be from a <c:set> tag.
    Invocation target exception would meant that an error was encountered calling the setter.
    That would focus on this part of the code:
    <!-- this tag uses c:set to set the property of a JavaBean -->
    <c:set target="${questions}" property="topic" value="JSTL" />
    <tr>
    <td><c:set target="${'${'}questions}" property="topic"
    value="JSTL"/>
    </td>That nesting of ${ } inside ${} looks dodgy to me. What is it you are trying to achieve?

  • Accesing a List within A List Using JSTL

    Hi,
    I am trying to access a property of an object within a List Object which again is in a List object using JSTL.
    List----List----Obj1----Property1 <--( I want to print this in a Table on a JSP)
    I am unable to figure out how to do it using the <c:forEach> tag.
    Thanks in advance,
    Shardul.
    Message was edited by:
    shardul.bhatt

    Hi,
    Thanks for your response. Actually I wanted a single statement to do this. Its my mistake I should have put the question in a different manner.
    Something like
    <c:out value="${requestScope.OUTER_LIST.[FIRST_INSTANCE_OF_INNER_LIST].[OBJECT].[PROPERTY]}" ></c:out>The OuterList has many InnerLists and each InnerList has many Objects. The Property of the first Object in the InnerList is what I want to print as a 'Title' of a table.
    For example: The Objects in the Inner List are UserObjects, where all the Users of a particular type are put together in an InnerList. I want to display the users of different types grouped together and the Table should have the 'User Type' as its title.
    I could do it like this
    <tr border="2" class="selectedrow">
    <td><B><font color="#2d5c3d">User Type</font></B></td>
    <td><strong><font color="#2d5c3d">
    <!---I want to remove this with a single line of code-->
    <c:forEach items="${usersByType}"   var="user" begin="0" end="0">
          <c:out value="${user.userType}"></c:out>
    </c:forEach>
    <!---I want to remove this with a single line of code-->
    </font></strong></td>But I think there has to be a better way to do it.
    BR,
    Shardul

  • Re: [iPlanet-JATO] using begin childName Display method

    Oops. Sorry about that, Craig. I didn't realize I might leave that impression.
    I'm sure the tiled
    views work since you have so many examples of these and it's a relatively
    simple concept, isn't it?
    Not to mention a necessary one. I didn't have time to debug my code and find
    out what I was doing
    wrong where the tiled views are concerned. I decide to just try to implement
    tiled views later and
    just stick with one of everything for now and get that working.
    Yes, I have reviewed your comments and am taking them into consideration. I am
    able to save and
    retrieve values with my model at this point.
    Thanks.
    Belinda
    X-eGroups-Return:
    sentto-2343287-1143-1008622698-belinda.garcia=sun.com@r...
    X-Sender: craig.conover@s...
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4)Gecko/20011019 Netscape6/6.2
    X-Accept-Language: en-us
    From: "Craig V. Conover" <craig.conover@s...>
    X-Yahoo-Profile: cvconover
    Mailing-List: list [email protected]; contact
    [email protected]
    Date: Mon, 17 Dec 2001 13:00:10 -0800
    Subject: Re: [iPlanet-JATO] using begin<childName>Display method
    Content-Transfer-Encoding: 7bit
    Belinda,
    He may also be binding the models, howerver, he needs to change the way
    the value appears before it is displayed which is why you would use the
    display events.
    Your null value issue is a completely different issue and has nothing to
    do with it being a tiled view. I don't want anyone getting the idea
    that the tiledView binding is broken. It does work. You issue should
    have something to do with the inconsistent way in which you are getting
    your model. At least from what I could tell in your source code that you
    sent me.
    Have you reviewed my comments I sent to you in your source code?
    craig
    Belinda Garcia wrote:
    I don't currently use a begin or end Display method. I merely bind the
    fields to
    the model when the child is created and use the setValue to initially setthe
    value to what's in the model. I get nulls though if I try to use a tiledView. I
    haven't quite got this figured out.
    Belinda
    X-eGroups-Return:
    sentto-2343287-1135-1008613974-belinda.garcia=sun.com@r...
    X-Sender: stephen_winer@y...
    User-Agent: eGroups-EW/0.82
    From: "stephen_winer" <stephen_winer@y...>
    X-Originating-IP: 155.188.191.4
    X-Yahoo-Profile: stephen_winer
    Mailing-List: list [email protected]; contact
    [email protected]
    Date: Mon, 17 Dec 2001 18:32:48 -0000
    Subject: [iPlanet-JATO] using begin<childName>Display method
    Content-Transfer-Encoding: 7bit
    I want to be able to conditionally show/hide data as well as format
    it for display without touching the model. I found the
    begin<childName>Display and end<childName>Display methods that
    provide the hooks to do this, but I have been unsuccessful in getting
    these method to execute. I added the fireChildDisplayEvents="true"
    attribute to the jato:useViewBean tag, but this has not helped. I
    also added some debug to the ContainerViewBase class in the public
    boolean beginChildDisplay(ChildDisplayEvent event) method to see what
    was happening. The displayMethodMap was returning null for the child
    display methods that were in the view bean. I covered all the bases
    (compiling, redeploying, etc.) and nothing has worked. Is there
    anything I am missing or is there some working example of this?
    Steve
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp

    The hidden field was present in the page, but it looked like this:
    <input type="hidden" name="jato.defaultCommand" value=""../search"">
    Seems like there is a small bug in the code generating this tag.
    FYI - I am using JATO1.2
    What file displays this text? Maybe I can go in and fix it and rejar
    it.
    Steve
    --- Mike Frisino wrote:
    Steve,
    Can you check the HTML source that shows up in the browser? Do you see an entry that looks like this at the bottom of the form in
    question?
    >
    <input type="hidden" name="jato.defaultCommand" value="/search">
    To answer your question - it should work as you described. Some of the JatoSample make use of the defaultCommandChild. Can you try
    running the sample BasicSample->Field Types and let us know what you
    see.
    >
    Failing this you can send me your jsp file , maybe there is some subtle issue there. michael.frisino@s...
    >
    >
    ----- Original Message -----
    From: stephen_winer
    Sent: Friday, December 07, 2001 8:05 AM
    Subject: [iPlanet-JATO] Using the defaultCommandChild in a form
    I am trying to set the defaultCommandChild in my jato:form tag to be
    the searcg button. The search button definition is:
    <jato:button name="search"/>.
    The form tag definition is:
    <jato:form name="PendingIA" defaultCommandChild="/search">
    Clicking on the search button works fine, but hitting return in one
    of the textFields (which submits the form) passes a value of "" to
    the createChild method in my viewBean, which throws an error. Why
    does this not just work as normal and trigger the handleSearchRequest
    () method?
    Steve
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    Service.
    >
    >
    >
    [Non-text portions of this message have been removed]

  • HT3382 I have a Samsung VGA Monitor connected to my MacBook Pro using the Mini Display Port to VGA Adapter.  How do I configure the computer so that it doesn't sleep when I close the lid of the computer.

    I have a Samsung VGA Monitor connected to my MacBook Pro using the Mini Display Port to VGA Adapter.  How do I configure the computer so that it doesn't sleep when I close the lid of the computer.

    Hi alangium,
    Welcome to the Support Communities!
    Resetting your computer's PRAM should restore your Macbook Pro's screen appearance.
    OS X Mavericks: Reset your computer’s PRAM
    http://support.apple.com/kb/ph14222
    This article may provide some information about your Mini DisplayPort to AVI adapter.  Have you tried to connect a different VGA monitor to your Macbook to see if you get the same results?
    Apple Mini DisplayPort adapters: Frequently asked questions (FAQ)
    http://support.apple.com/kb/HT3382
    18. What is the maximum resolution available for use with the Apple Mini DisplayPort to VGA adapter?
    The resolution available with the Apple Mini DisplayPort to VGA Adapter is 1920 x 1200. VGA displays that use higher refresh rates (such as 85 Hz) at resolutions of 1600 x 1200 or greater may not generate video properly until you lower the refresh rate.
    Apple computers: Troubleshooting issues with video on internal or external displays
    http://support.apple.com/kb/HT1573#5
    How can I detect displays?
    If the detect displays option is not available, hold down the Option key while you are in the Display pane.
    How do I select additional resolutions on my display?
    You can use the Display pane of System Preferences to specify how your display works. Not all options appear for all display models. By default the best resolution for your display will already be selected in System Preferences.
    To select a different resolution, use the Scaled option. Some additional resolutions may be available when you hold the Option button.
    I hope this information helps ....
    - Judy

Maybe you are looking for

  • Automatic change of text size and shape in pages from master

    Hi, I'm new to Indesign and I'm trying to write a long book which is more like a catalog. I've created a book file (.indb) in which various files (.indd) are inserted. Each of these files will represent a chapter. All chapters must have the same aspe

  • InDesign (CS3, 5.5 and 6) chrashes while opening a P65

    Hi there, grey hairs aproaching here: I have a near to ancient P65 file. InDesign won't open it, it crashes during the loading process (table attributes?). That happens even after opening it in PageMaker and saving a new copy. Since it's a quite comp

  • Rich Symbol Contents don't update properly

    Hi Fireworks people, I have a Rich Symbol in which you can type text and set a few properties. Saving works but sometimes when there are many instances of this Rich Symbol in a document only parts of the entered text are displayed on the stage. In th

  • The form can not be saved if open with adobe reader

    Hi all, I create a registration form using Adobe LiveCycle Designer 8.0.1291 then I Save As both into static and dynamic Then when I'm open the registration form file using Adobe Reader 9 then there's message appearing says "Please Fill it up this fo

  • W or who don't show list of users

    w or who don't show a proper list of logged users # w 23:46:22 up  5:48,  1 user,  load average: 0.49, 0.28, 0.14 USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT although i got 2 users logged in, it's really strange..