JSTL XPATH question

I am using the XML taglib from JSTL 1.1 (SDK 1.5.0_03, Tomcat 5.5.9) in a JSP page. I am unable to get a node-set count; it always returns 0. I can loop through the docment and retrieve values, but no node functions (count( ), position( ), etc.).
Example:
<x:out select="count($doc/INVOICE_SETUPS/INVOICE_SETUP)" />
Does anyone have an idea as to what this could be? Any information would be greatly appreciated.
William

William,
I have had the same problem and it is indeed painful. Try this as a start:
     <x:out select="name($doc)" />      If you have the same problem I've had then the name of this node list will not be what you expected.
I think I have finally found the solution, as follows. The confusion I had was over the contents of the rowset resulting from use of x:parse. Firstly, these are my taglib prefixes:
<%@ taglib prefix="c" uri="/jstl/core" %>
<%@ taglib prefix="x" uri="/jstl/xml" %>
<%@ taglib prefix="sql" uri="/oracle/sql" %>      I then have the result of an Oracle query in XML form assigned to a variable using c:set:
<c:set var="resultslist">
     <sql:dbQuery output="XML" bindParams="search">
            SELECT LISTID, ...
            FROM ...
            WHERE ...
            ORDER BY ...
     </sql:dbQuery>
</c:set>      Now I can loop over the result using the following
          <x:parse xml="${resultslist}" var="listentry"/>
          <x:forEach select="$listentry/ROWSET/ROW" var="rowxml">
               <x:out select="$rowxml/LISTID"/>
          </x:forEach>      So it appeared to me that the listentry variable resulting from x:parse xml="${resultslist}" was a node-set of parents of ROWSET. Then I tried:
          <x:parse xml="${resultslist}" var="listentry"/>
          <x:out select="name($listentry)"/>
          <x:out select="count($listentry)"/>
          <x:out select="count($listentry/ROWSET)"/>
          <x:out select="count($listentry/ROW)"/>      And the results were:
     ROWSET
     1
     0
     4           Four was the result I was looking for! So the solution was that the resultslist node-set was the ROWSET object in the <x:forEach> rather than its parent.
Hope this helps someone.
Andy Newton

Similar Messages

  • XML/XPath question--how to select a range of elements with XPath?

    Hi there,
    I have an XML DOM in memory. I need to do hold it and issue only parts of it to my client app in "pages". Each page would be a self-contained XML doc, but would be a subset of the original doc. So for instance the first page is top-level elements 1-5. 2nd page would be 6-10 etc. Is this solution best solved with XPath? If not, what's the best way? If so, I have the following question:
    Is there a way to use XPath to select a range of nodes based on position within the document? I know I can do an XPath query that will return a single Node based on position. So for example if I wanted the first node in some XML Book Catalog I could do XPathAPI.selectSingleNode(doc, "/Catalog/Book[position()=1]"); I could wrap the previous call in a loop, replacing the numeric literal each time, but that seems horribly inefficient.
    Any ideas? Thanks much in advance!
    Toby Buckley

    Your question is about marking a range of cells. 99% of the code posted has nothing to do with this. If you want to create a simple table for test purposes then just do:
    JTable table = new JTable(10, 5);
    JScrollPane scrollPane = new JScrollPane( table );
    getContentPane().add( scrollPane );
    In three line of code you have a simple demo program.
    When I leave the mouse button again, these bunch/range of cells shall stay "marked". table.setCellSelectionEnabled( true );
    and I'd like to obtain, say, a vector of a vector containing just those data marked beforeUse the getSelectedRows() and getSelectedColumns() methods for this information. I would suggest you create a Point object to reflect the row/column position and then add the point to an ArrayList.

  • Problem with getNodeValue() - simple Java XPath question

    I am trying to extract the node values from a XML file:
    <root>
      <frame>
         <boxes>
           <box>
              <spec>22</spec>
              <spec>2222</spec>
           </box>
           <box>
              <spec id="BA" value="short"/>
              <spec id="BB" value="thin"/>
              <spec id="BC" value="black"/>
              <spec id="BD" value="full"/>
              <spec id="BE" value="7"/>
              <spec id="BF" value="deactive"/>
           </box>                
         </boxes>
         <circles>
           <circle id="CA" value="blue"/>
           <circle id="CB" value="green"/>
         </circles>
      </frame>
    </root>I use this code:
             XPathFactory factory = XPathFactory.newInstance();
             XPath xpath = factory.newXPath();
             XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec");            
             Object result = xPathExpression.evaluate(doc, XPathConstants.NODESET);
             NodeList nodes = (NodeList) result;
             for (int i = 0; i < nodes.getLength(); i++) {
                 System.out.println(nodes.item(i).getNodeValue());
             }But only:
    null
    null
    null
    null
    null
    null
    null
    null
    get printed. I would have assumed:
    22
    2222
    null
    null
    null
    null
    null
    null
    since the two first spec nodes contains the above numbers. Any ideas?

    change this:
    XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec");to this:
    XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec/text()");Need to xpath all the way down to the text of the node.
    You could use
    System.out.println(nodes.item(i).getTextContent());with your current xpath but if the spec node has children, these will also be included in the output.

  • XSLT Xpath question

    Hello all,
    I am kind of a newbie to the xpath sort of translation.
    I am curious on how to:
    Grab the last element with data from the input side of my xsl ?
    I appreciate any help on this.
    Jaden

    I guess I should explain what I am trying to accomplish :)
    I am trying to map an inbound 856 thru the xsl transformation.
    in the pack loop is the delivery detail id. under that are several item loops.
    My issue is that the Item Loop has the serial number where the Pack loop has the delivery detail. I need to copy the deliver detail id for each of the items for the output side of my transformation.
    I use the code /ns1:Transaction-856/ns1:Loop-HL/ns1:Segment-LIN/ns1:Element-234_1[last()]
    But i get only the first number in my output?
    Ty in advance
    Jaden

  • XPath question

    I am trying to populate an accordion using an XML document as
    follows:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <images xmlns="
    http://www.g-raff.com/images">
    <groups>
    <group groupname="Martyn's favourites">
    <image>
    <filename>atomic-kitten-1.jpg</filename>
    <title>Atomic Kitten</title>
    <date>23.8.2004</date>
    <place>London</place>
    </image>
    <image>... </image>
    etc.
    </group>
    <group groupname="Painting with light">
    <image>
    <filename>a.jpg</filename>
    <title>a</title>
    <date>15.4.2003</date>
    <place>peckham rye</place>
    </image>
    etc.
    </group>
    <group groupname="Musicians">
    <image>
    <filename>atomic-kitten-1.jpg</filename>
    <title>Atomic Kitten</title>
    <date>23.8.2004</date>
    <place>London</place>
    <target>people1</target>
    </image>
    etc.
    </group>
    </groups>
    </images>
    Now - in creating the data sets, I want to generate a set of
    thumbnails for each "group" - I have the following code:
    var dsGroups = new Spry.Data.XMLDataSet("images.xml",
    "/images/groups/group");
    var dsImages = new Spry.Data.XMLDataSet("images.xml",
    "/images/groups/group[@groupname =
    '{dsGroups::@groupname}']/image")
    I am then using the following to label the accordion and
    populate the panels:
    <div id="NavAcc" class="Accordion" spry:region="dsGroups
    dsImages">
    <div class="AccordionPanel" spry:repeat="dsGroups">
    <div class="AccordionPanelLabel">
    <h3>{dsGroups::@groupname}</h3>
    </div>
    <div class="AccordionPanelContent">
    <div id="thumbs">
    <div class="thumbnail" spry:repeat="dsImages">
    <img class="thumb"
    src="images/thumbnails/{dsImages::filename}"
    alt="{dsImages::title}"
    onclick="dsImages.setCurrentRow('{ds_RowID}');" width="92"
    height="60" />
    <p class="caption">{dsImages::title}</p>
    </div>
    </div>
    </div>
    </div>
    </div>
    Its not working - dsImages is failing. I know it must be to
    do with the way I'm trying to filter by the attribute "groupname",
    as I'm not sure whether the "@" is allowed in this context.
    Can anyone point me at a fulfilling explanation of xPath
    syntax so I can figure out how to achieve this?
    Thanks yet again,
    raff J

    I encountered the same (or very similar) problem. In my case,
    with a photo album xml where the layout is similar (see below) and
    I need to pull the image folder url from the parent dataset and the
    image urls from a series of <img> tags. I also could not
    figure out a way to do this, and would very much appreciate an
    example of how it is done.
    what did not work was setting up the datasets as
    var dsPhotos = new Spry.Data.XMLDataSet("sample.xml",
    "gallery/album")
    var dsImages = new Spry.Data.XMLDataSet("sample.xml",
    "gallery/album[@pID = '{dsPhotos::pID}']/img")
    Sample XML:
    <?xml version="1.0" encoding="utf-8"?>
    <!-- XML Generated by SlpIDeShowPro Director v1.0.2 -->
    <gallery>
    <album pID="8" title="Rose River" description="Rose River
    Hike" lgPath="
    http://www.zakar.com/ssp_director/albums/RoseRiver/lg/"
    tnPath="
    http://www.zakar.com/ssp_director/albums/RoseRiver/tn/"
    tn="
    http://www.zakar.com/ssp_director/albums/RoseRiver/tn/P5030196.jpg">
    <img src="P5030211.jpg" title="" caption="P5030211.jpg"
    link="
    http://" />
    <img src="P5030196.jpg" title="" caption="P5030196.jpg"
    link="
    http://" />
    <img src="P5030197.jpg" title="" caption="P5030197.jpg"
    link="
    http://" />
    </album>
    <album pID="9" title="Stony Man / Little Stony Man
    Cliffs" description="Great views " lgPath="
    http://www.zakar.com/ssp_director/albums/Stonyman/lg/"
    tnPath="
    http://www.zakar.com/ssp_director/albums/Stonyman/tn/"
    tn="
    http://www.zakar.com/ssp_director/albums/Stonyman/tn/P5020182.jpg">
    <img src="P5020195.jpg" title="" caption="P5020195.jpg"
    link="
    http://" />
    <img src="P5020178.jpg" title="" caption="P5020178.jpg"
    link="
    http://" />
    <img src="P5020179.jpg" title="" caption="P5020179.jpg"
    link="
    http://" />
    </album>
    </gallery>

  • Spry XPath question

    This is a multi-part message in MIME format.
    ------=_NextPart_000_00F9_01C6872E.F574B670
    Content-Type: text/plain;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    I have an XML file which describes vacation listings. It is
    divided into =
    major locations (in the code below, U.S. and Mexico) which,
    in turn, =
    include property listings and details. I've gotten it to work
    in a basic =
    master-detail page, but only by ignoring the major locations.
    (In my =
    data set creation code, the XPath expression points to =
    "vacations/location/property"). What I'd really like is to do
    something =
    like this following:
    Region Location Property
    US Florida Vista Hills
    Vancouver Northern Palace
    Mexico Cancun Playa de Picante
    Would I need two data sets to pull this off?
    Best - Joe
    <?xml version=3D"1.0" encoding=3D"iso-8859-1"?>
    <vacations>
    <location>
    <place>U.S.</place>
    <property>
    <name>Vista Hills</name>
    <destination>Florida</destination>
    <contact>407-555-1234</contact>
    <description>The perfect family vacation resort, near
    all area =
    amusement parks.</description>
    <image>vista_hills.jpg</image>
    </property>
    <property>
    <name>Northern Palace</name>
    <destination>Vancouver</destination>
    <contact>407-555-5678</contact>
    <description>Enjoy great shopping and whale watching
    in the ultimate =
    stylish setting.</description>
    <image>northern_palace.jpg</image>
    </property>
    </location>
    <location>
    <place>Mexico</place>
    <property>
    <name>Playa de Picante</name>
    <destination>Cancun</destination>
    <contact>+52-998-555-1234</contact>
    <description>Fun in the sun to the max - don't miss
    the vacation of a =
    lifetime.</description>
    <image>picante.jpg</image>
    </property>
    </location>
    </vacations>
    ------=_NextPart_000_00F9_01C6872E.F574B670
    Content-Type: text/html;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=3DContent-Type content=3D"text/html; =
    charset=3Diso-8859-1">
    <META content=3D"MSHTML 6.00.2900.2873"
    name=3DGENERATOR>
    <STYLE></STYLE>
    </HEAD>
    <BODY>
    <DIV><FONT face=3DArial size=3D2>I have an XML
    file which describes =
    vacation=20
    listings. It is divided into major locations (in the
    code below, =
    U.S. and=20
    Mexico) which, in turn, include property listings and
    details. I've =
    gotten it to=20
    work in a basic master-detail page, but only by ignoring the
    major =
    locations.=20
    (In my data set creation code, the XPath expression points to
    "<SPAN=20
    style=3D"FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: Arial;
    =
    mso-fareast-font-family: 'Times New Roman';
    mso-bidi-font-family: 'Times =
    New Roman'; mso-ansi-language: EN-US; mso-fareast-language:
    EN-US; =
    mso-bidi-language:
    AR-SA">vacations/location/property</SPAN>").=20
    What I'd really like is to do something like this =
    following:</FONT></DIV>
    <DIV><FONT face=3DArial
    size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial=20
    size=3D2><U>Region        Locatio=
    n       =20
    Property</U></FONT></DIV>
    <DIV><FONT face=3DArial=20
    size=3D2>US          &n=
    bsp;  =20
    Florida        
     Vista=20
    Hills</FONT></DIV>
    <DIV><FONT face=3DArial=20
    size=3D2>          &nbs=
    p;       =20
    Vancouver    Northern
    Palace</FONT></DIV>
    <DIV><FONT face=3DArial =
    size=3D2>Mexico       =20
    Cancun         Playa
    de=20
    Picante</FONT></DIV>
    <DIV><FONT face=3DArial
    size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2>Would I need two
    data sets to pull this =
    off?</FONT></DIV>
    <DIV><FONT face=3DArial
    size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2>Best -
    Joe</FONT></DIV>
    <DIV><FONT face=3DArial
    size=3D2></FONT> </DIV>
    <DIV><FONT face=3D"Courier New"
    size=3D2>&lt;?xml version=3D"1.0"=20
    encoding=3D"iso-8859-1"?&gt;<BR>&lt;vacations&gt;<BR>&lt;location&gt;<BR>=
     &lt;place&gt;U.S.&lt;/place&gt;<BR> &lt;property&gt;<BR> =
     &lt;name&gt;Vista=20
    Hills&lt;/name&gt;<BR>  &lt;destination&gt;Florida&lt;/destinat=
    ion&gt;<BR>  &lt;contact&gt;407-555-1234&lt;/contact&gt;<BR>&nb=
    sp; &lt;description&gt;The=20
    perfect family vacation resort, near all area amusement=20
    parks.&lt;/description&gt;<BR>  &lt;image&gt;vista_hills.jpg&lt=
    ;/image&gt;<BR> &lt;/property&gt;<BR> &lt;property&gt;<BR>&nbsp=
    ; &lt;name&gt;Northern=20
    Palace&lt;/name&gt;<BR>  &lt;destination&gt;Vancouver&lt;/desti=
    nation&gt;<BR>  &lt;contact&gt;407-555-5678&lt;/contact&gt;<BR>=
      &lt;description&gt;Enjoy=20
    great shopping and whale watching in the ultimate stylish=20
    setting.&lt;/description&gt;<BR>  &lt;image&gt;northern_palace.=
    jpg&lt;/image&gt;<BR> &lt;/property&gt;<BR>&lt;/location&gt;<BR>&lt;=
    location&gt;<BR> &lt;place&gt;Mexico&lt;/place&gt;<BR> &lt;prop=
    erty&gt;<BR>  &lt;name&gt;Playa=20
    de=20
    Picante&lt;/name&gt;<BR>  &lt;destination&gt;Cancun&lt;/destina=
    tion&gt;<BR>  &lt;contact&gt;+52-998-555-1234&lt;/contact&gt;<B=
    R>  &lt;description&gt;Fun=20
    in the sun to the max - don't miss the vacation of a=20
    lifetime.&lt;/description&gt;<BR>  &lt;image&gt;picante.jpg&lt;=
    /image&gt;<BR> &lt;/property&gt;<BR>&lt;/location&gt;<BR>&lt;/vacati=
    ons&gt;</FONT></DIV></BODY></HTML>
    ------=_NextPart_000_00F9_01C6872E.F574B670--

    Thanks, Kin -
    I figured out how to create the two data sets as you
    described, but was
    looking for the single list solution with nested repeating
    nodes.
    Looking forward to your solution!
    Best - Joe
    "kinblas" <[email protected]> wrote in
    message
    news:e62dkj$qun$[email protected]..
    > Hi Joe,
    >
    > If you are trying to display the info for "place",
    "name" and
    > "destination"
    > all in one table or list we can't handle that at the
    moment due to the way
    > we
    > flatten the XML into a data set. Repeating nodes
    underneath repeating
    > nodes get
    > discarded.
    >
    > We're working on a solution though.
    >
    > We can handle your XML structure with a Master/Detail
    pattern though.
    >
    > var dsPlaces = new XMLDataSet("location.xml",
    > "/vacations/location/place");
    > var dsProperties = new XMLDataSet("location.xml",
    > "/vacations/location[place =
    > '{dsPlaces::place}']/property");
    >
    > Using data sets like the above would assume that you'd
    have a place for
    > users
    > to click on a list of places and the detail area would
    display the
    > properties
    > for the currently selected place.
    >
    > --== Kin ==--
    >

  • Simple XPATH question

    Hi everybody,
    I'm trying to figure how to code my XPATH expression to get some information inside a XHTML page.
    If I use that XPATH:
    /tr/span/td[@id="COL"]/spanI get this:
    &lt;span id="check31"&gt;
      &lt;input value="31"/&gt;
    &lt;/span>
    &lt;span id="check32"&gt;
      &lt;input value="32"/&gt;
    &lt;/span&gt;
    &lt;span id="check33"&gt;
      &lt;input value="33"/&gt;
    &lt;/span&gt;In that result, I only want the second &lt;span&gt; tag. How do I code my XPATH ?
    I tried this:
    /tr/span/td[@id="COL"]/span[2]but it doesn't work.
    Currrently, as a work around, I code something like this:
       select extract(extract(V_XMLTYPE,
                              '/tr/span/td[@id="COL"]/span'), '/span[2]')
         from dual;Thank you for any help.

    change this:
    XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec");to this:
    XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec/text()");Need to xpath all the way down to the text of the node.
    You could use
    System.out.println(nodes.item(i).getTextContent());with your current xpath but if the spec node has children, these will also be included in the output.

  • XPath question (select on tag string contents)

    Hi,
    I have the following XML file (a wikinews dump):
    <mediawiki>
      <page>
        <title>Image:Wiki.png</title>
        <id>1</id>
        <restrictions>move=sysop:edit=sysop</restrictions>
        <revision>
          <id>92375</id>
          <timestamp>2005-06-29T02:57:00Z</timestamp>
          <contributor>
            <username>NGerda</username>
            <id>2442</id>
          </contributor>
          <text xml:space="preserve">Wikinews logo.
    {{CopyrightByWikimedia}}</text>
        </revision>
      </page>
    </mediawiki>(with more <page> elements of course)
    I would like to only select those pages (titles and text) where the title does not contain 'category:' or 'Image:' or 'Template:' etc. or just does not contain ':' (I do not have all the pages, only most of them).
    What would be the right XPath expression?
    Any help is greatly appreciated!
    GrandiJoos
    Edited by: Grandi on Oct 6, 2007 7:05 AM
    Expanded topic title

    Something like:
    /mediawiki/page[not(contains(title, ':'))]

  • XPath Question related to xsi:type

    I have the response of a service callout that I need to process. The service callout response uses xsi:type to specify the type of the object being returned. I need to use the value of the xsi:type attribute to collect the xml elements.
    Here is the xpath that I am trying to use:
    $addAssetInfoResponse/ast:addAssetInfoResponse/ast:result/ast:asset\[local-name-from-QName(attribute::xsi:type)='Customer'\]
    (ast: is mapped to http://www.fatspaniel.com/ws/asset/)
    When I test this XPath with the following XML fragement as value of addAssetInfoResponse variable:
    <env:Body xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <ns2:addAssetInfoResponse xmlns:ns2="http://www.fatspaniel.com/ws/asset/" >
    <ns2:result>
    <ns2:status>SUCCESS</ns2:status>
    <ns2:asset xsi:type="ns4:Customer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="http://www.fatspaniel.com/ws/sysobj/" >
    <entityId>106934</entityId>
    <type>Customer</type>
    <name>AAI Customer - 200909081651</name>
    </ns2:asset>
    </ns2:result>
    </ns2:addAssetInfoResponse>
    </env:Body>
    I get the following error:
    Error executing the transformation: {err}XP0021: "ns4:Customer": can not cast to {http://www.w3.org/2001/XMLSchema}QName: error: Invalid QName value: Can't resolve prefix 'ns4'
    Have I made a mistake in the xpath ? Is there a better way for extracting assets elements of certain type ?
    Thank you.
    Rahul Phadnis
    Edited by: RahulPhadnis on Sep 15, 2009 10:57 AM

    John Spencer wrote:
    Unless I missed something in the 11g new features, the maximum line length in DBMS_OUTPUT.Put_Line is still 255 characters.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> set serveroutput on
    SQL> exec dbms_output.put_line(lpad('X',512,'X'));
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    PL/SQL procedure successfully completed.
    SQL> SY.

  • JSTL Tag Question - forEach

    Hi there, I have this piece of code;
    <c:forEach var="row" items="${linkQuery.rows}" varStatus="status">
    <tr>
    <td>
    <c:out value="<%= altField %>"/>
    </td>
    </tr>
    </c:forEach>
    You see the field to be displayed is a variable; altField, of which the string value is;
    "${row.SOMEFIELDNAME}"
    however when run, it simply prints out the value between the speech marks rather than evaluating the expression.
    It prints;
    <c:out value="<%= altField %>"/>
    Instead of;
    <c:out value="${row.SOMEFIELDNAME}"/>
    I ve tried escaping the speech marks however I get a compilation error if I try this.
    It needs to be a variable because the field name varies on each instance. Any help greatly received,
    Simon.

    I'm not sure if you've tried this, but I think it ought to look like:
    <c:forEach var="row" items="${linkQuery.rows}" varStatus="status">
    <tr>
    <td>
    <c:out value="${row.SOMEFIELDNAME}"/>
    </td>
    </tr>
    </c:forEach>It sounds like you're mixing and matching the EL and scriptlets - not a good idea. That's what the EL is for - getting all that scriptlet code out of your JSPs.
    My JSPs print successfully doing it this way. See if yours does, too. - MOD

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

  • Dom4j xpath problem

    Hello all
    I have several methods in which I noticed strange behavior
    Here is the example:
    I create xpath as object because of performance, cause i use it on thousands of files
    XPath pathSpanPodzakonska = DocumentHelper.createXPath("//span[@class='palnk']");
    I found h4 element via xpath with relative path to h4 element...
    That works fine so far and founds h4 element that I need to.
    final Element elementH4= (Element) document.selectSingleNode("//h4[@id='someId']");
    Now i need to found some element inside that h4 tag
    but what I get is first element in document, outside h4 element !!!
    final Node nodeSpanPodzakonska = pathSpanPodzakonska.selectSingleNode(elementH4);
    That works same even if i write
    final Node nodeSpanPodzakonska = elementH4.selectSingleNode("//span[@class='palnk']");
    If I write code with absolute xpath that works fine when the span is directly inside of h4 but this isn't always case and cant depend on that.
    And more important have some other similar methods and want to clarify what happens in this xpath implementations and how can I use it in the best way.
    final Node nodeSpanPodzakonska = elementH4.selectSingleNode("span[@class='palnk']");
    Danilo Cubrovic

    Sorry. I will have to think about the XPath question in more detail.
    As to the side by side comparison: I meant of - open source HTML parsers
    http://java-source.net/open-source/html-parsers
    and also of XML frameworks that support XPath (such as DOM4j vs XOM).
    I am going to try HTMLParser with XOM, as I have, in informal speed testing, seen HTMLParser to be quite fast compared to others.
    The reason I would like to have speed is that I am working on a Web automation toolkit:
    www.mkosh.com
    and it looks like I will be re-parsing the entire tree after many Javascript commands.
    I would like to make this as speedy as possible. HTMLParser seems to win hands down, although if it does not work with real world HTML, that could be an issue.
    I will have to test.
    Thank you so much
    Misha

  • Best way to perform the same task wih arrays of different Objects

    Hello all.
    This isn't an XPath question, it's a much lower-level Java Object question, but it involves XPath. I hope that doesn't distract from the question, or confuse anything.
    I have 4-5 different types of Objects (call them A, B, C, etc.) that each contain an array of other Objects (call them a[], b[], c[], etc.)
    a, b, c, etc., each have an Xpath object and and XPathExpression. When I create each XPath object I assign it a NamespaceContext object which contains the namespaces needed for that XPath.
    When I create, for example, an A object, I pass is constructor an array of a and an array of Namespaces. With each a object I need to:
    1. create a NamespaceContext object
    2. go through all the Namespace objects and if its route matches,
    (if Namespace.route == a.getRoute() )
    3. add that Namespace to the NamespaceContext Object,
    4. assign the NamespaceContext to the XPath object, and finally
    5. create the a object, passing it the XPath object
    My problem / question is: I also have to do the same thing with B and b[], C and c[], etc. It's not that long of a process, not that much code, but all the same, I was wondering what the best way to write this code once would be, and have it work for all the different types of Objects.
    In other words, I'd like to write a mehod, call it assignNamespaces(), that accepts an array of Objects(a[], b[], c[], etc.) and an array of Namespaces, creates the XPath Object for each a, b, c, etc., and that creates and returns an array of a[],b[],c[], etc., sending the XPath Object as a parameter.
    That way when I create for example an A Object, I call:
    class A
    ObjectsWithXpath[] objectsWithXPath;
    this..objectsWithXPath = assignNamespaces(objectsWithXPath,namespaces);
    Should the assgnNamespaces() method simply use Class.forName() to see what type of Object it is and do a cast accordingly, or is there some other, more elegant way of doing this?
    I hope I've explained myself, and haven't bored you ...
    Thanks in advance,
    Bob

    Thanks for your reply!
    I poked around a bit looking into Factory classes. I've used them a million times but never actually made one. At any rate, they seem like a good idea when you have a bunch of different classes that are similar but not equal.
    In my case my classes ONLY have the XPathExpression in common. Which means that I'd have to make a base abstract class with a bunch of methods of which only a percentage are defined by any class that extends it. In other words, if I had 3 classes -- a, b and c -- that extend the base abstract class, and each had 5 getters and setters, the base abstract class would have 15 methods, 5 only used by a, 5 only used by b and 5 only used by c.
    It seemed a bit ugly to me. Besides, I only have 3 classes. I decided to factor out the inner loop, which is about 70% of the code, stick it in a utility class, and call it from there. I am repeating some code still, but it isn't that bad, and it saves me having to define an interface, an abstract class, a Factory class, etc.
    It ain't perfect, but then nothing ever is.
    Thanks for all the help! Viva the Java community!
    Bob

  • Schema and Forms: Ex 1 Quiz missing XML sample

    XPath question is missing this XML:
    <x>
      <y z="abc"/>
    </x>
    Should be fixed soon.

    i tryied same way as you tried.
    no other parser are working. i guess oracle parser is best, but i dont no why other schema files are not working
    if any one have better solution help us, we are wasting days for these at final results are nonthing. please help us if you have solution
    srinu

  • Getting

    Hi all,
    This is a most frustrating problem because everything appears to be set correctly, but here it goes.
    Two simple files
    C:\test\Test1.java
      package test;
      import java.util.*;
      public class Test1 {
        public Test1() { }
      }     and...
    C:\test\Test2.java
      package test;
      import java.util.*;
      public class Test2 {
        public Test2() {
          Test1 test1 = new Test1();
      } "C:\test>javac Test1.java" works fine and Test1.class is created.
    "C:\test>javac Test2.java" results in the following error
    C:\test>javac test1.java
    test2.java:7: cannot find symbol
    symbol : class Test1
    location: class test.Test2
    Test1 test1 = new Test1();
    ^
    test2.java:7: cannot find symbol
    symbol : class Test1
    location: class test.Test2
    Test1 test1 = new Test1();
    ^
    2 error
    Naturally I think it is a classpath issue, but here is my class path:
    CLASSPATH =
    C:\test;
    C:\test\;
    C:\j2ee\Ch04;C:\Program Files\Java\jdk1.5.0_11\bin;
    C:\Sun\AppServer1.4\lib\j2ee.jar;
    C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;
    C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;
    C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;
    C:\PROGRA~1\IBM\SQLLIB\bin;
    C:\PROGRA~1\IBM\SQLLIB\java\common.jar;
    C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cisuz.jar;
    C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cu.jar;
    C:\TIJ4\code;
    C:\J2EE\;
    The command "C:\test>javac -classpath . Test2.java" also doesn't work, same message.
    The command "C:\test>javac -classpath C:\test\ Test2.java" also the same.
    This error is occuring with every compile on my system that calls another of my class files.
    Any ideas? Do I need to reinstall?
    P.S. Java version = 1.5.0_11

    Thanks guys,
    I am beginning to understand this and have gotted those test files to work by adding "C:\" to the classpath (not a good fix but it helped me understand why.). This problem started, however with some other file that I'm still not able to get to work. Can you help me with these?
    The two files are...
    C:\J2EE\Ch04\WEB_INF\classes\Ch04\Questions.java
    package ch04;
    import java.util.*;
    import java.util.Map;
    import java.util.HashMap;
    public class Questions {
    <<Code omitted>>  public Questions() {
         questions.put("1", "How do I use implicit objects?");
         questions.put("2", "How do I use the JSTL?");
         questions.put("3", "How do I use the 'empty' operator?");
         setNumTopics(questions.size());
    }and...
    C:\J2EE\Ch04\WEB_INF\classes\Ch04\SimpleList.java
    package ch04;
    import java.util.*;
    import javax.servlet.jsp.tagext.*;
    import javax.servlet.jsp.*;
    import java.io.*;
    public class SimpleList extends SimpleTagSupport {
      private String topic;
      public void setTopic(String s) { topic = s; }
      public String getTopic() { return topic; }
      public void doTag() throws JspException {
         Questions questions = new Questions();
    <<Code omitted>>Since both files start with "package ch04;" I added the following to my classpath
    C:\J2EE\Ch04\WEB_INF\classes;
    Questions.java compiles fine, but ">javac SimpleList.java" returns the following message:
    simplelist.java:14: cannot find symbol
    symbol : class Questions
    location: class ch04.SimpleList
    Questions questions = new Questions();
    ^
    I also tried changing their projects to project ch04.web_inf.classes.ch04 and added "C:\J2EE;" to my classpath. Neither is working. Why?

Maybe you are looking for

  • How to call a repeater within a jsp file in web portal

    Hello, I wrote a Timer javascript to create a Timer thread that keep running and repeating for every 5 seconds. Basically, this javascript includes a StartTimer(), StopTimer() and UpdateTimer(), I also have a repeater to retrieve data from Oracle Dat

  • Someone keeps changing the password on my apple id and apple not responding to calls.

    2 hours ago i recieved a wave of emails saying my appleID password was changed, and the credit information was changed. I went and sure enough the password was incorrect. I recovered the account to find the Account holders name to be: <edited by host

  • Looking for a second display

    Hi again. I'm looking for a screen to go with my 21.5 Inch iMac. This would be mainly used for gaming with my Xbox 360 however I would use it with my Mac as well. It also needs to be height adjustable so that I can align it perfectly with my Mac. So

  • Part nunbers for smf Metro cables

    Does anyone know the cisco part number for the small jumper cables used to connect the Metro 1500 WCM cards together? They are anywhere from 6 inches to a foot long, mini-SC connectors on both ends. thanks. - Ted

  • Making variables global i iAd Producer

    sorry if this is a really simple question. Still, I am stuck: I would like to have widgets access other widget's variables. I would have thought, for instance, that it would be possible to declare a variable var Utility = this.viewController.outlets.