Solved

how to find size of the feeds at JSTL

Posted on 2010-09-04
14
205 Views
Last Modified: 2013-11-18
Hello

I need to find the size of the JSTL and write it to end="size of the feed " at the following code. Could you please help me how to find the size of the feed?

Regards
Altaico

 <x:forEach begin="0" end="4" var="story"
                   select="$doc/rss/channel/item" varStatus="status">
//end = "size of the rss"
0
Comment
Question by:elaltaico
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
14 Comments
 
LVL 27

Expert Comment

by:rrz
ID: 33603559
Do you want to know item count ?
<x:forEach begin="0" end="4" var="story"
                   select="$doc/rss/channel/item" varStatus="status">
<c:set var="itemCount" value="${itemCount +1}" />
</x:forEach> 
Item count is <c:out value="${itemCount}" />

Open in new window

0
 

Author Comment

by:elaltaico
ID: 33603628
Hello

i want to end rss at the end of the item count . it means it will begin from 0 and end at the last.(all the items). So how i can write itemcount without writing it inside <x:forEach begin="0" end="4">

Cheers
0
 

Author Comment

by:elaltaico
ID: 33603640
or is there any specific method that i can find feed sizE?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:rrz
ID: 33604607
>So how i can write itemcount without writing it inside <x:forEach begin="0" end="4">  
If you want to find the number of items, then you can use XPath function in a JSTL <x:out>  tag.
<x:out select="count($doc//item)" />  
If that is not what you want, then please define
>feed sizE  
0
 

Author Comment

by:elaltaico
ID: 33605733
       <x:forEach var="story" begin="0" end="<x:out select='count($doc/rss/channel/item)'/>"
                   select="$doc/rss/channel/item" > should work but it does not :((

Error is :java.lang.NumberFormatException: For input string: "<x:out select='count($doc/rss/channel/item)'/>"
      java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
0
 
LVL 27

Expert Comment

by:rrz
ID: 33606787
I am sure what you are trying to do here.
Why do need to know the number of items in advance ?
If you just want to loop through the nodeset, then you don't have to use the begin and end attributes. Please try the following example code.
Number of items is <x:out select="count($doc//item)" /><br/>
<x:forEach select="$doc/rss/channel/item" > 
        <x:out select="title/text()" /><br/>
</x:forEach>

Open in new window

0
 
LVL 27

Expert Comment

by:rrz
ID: 33606790
error
I am *not* sure what you are trying to do here.
0
 

Author Comment

by:elaltaico
ID: 33606797
rrz@871311 I need to put 4 rss item at one page and next page will use same URL but differnet begin point and different end point.As a result of that I need to get size of rss and make a mathematical function to put 4 rss feed at one page and put the remaining rss feeds at last page. That'S why I need to get rss feed size at beginning. I hope I was clear. Apologizes if I was not clear at beginning. Thank you in advance.


Regards
0
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 33606867
Please try the following example code.
<x:set select="count($doc//item)" var="itemCount" />
<br/>First page:<br/>
<x:forEach var="story" begin="0" end="3" select="$doc/rss/channel/item" > 
                      <x:out select="title/text()" /><br/>
</x:forEach>
<br/>Second page:<br/>
<x:set select="count($doc//item)" var="itemCount" />
<x:forEach var="story" begin="4" end="${itemCount}" select="$doc/rss/channel/item" > 
                      <x:out select="title/text()" /><br/>
</x:forEach>

Open in new window

0
 
LVL 27

Expert Comment

by:rrz
ID: 33606886
That last code will work for on a single page. If you want to display on separate pages, then add scope attribute.
<x:set select="count($doc//item)" var="itemCount" scope="session" />
Make doc session-scoped as well.
0
 
LVL 27

Expert Comment

by:rrz
ID: 33606900
Error: no need to set itemCount twice.
Please try the following example code.
<x:set select="count($doc//item)" var="itemCount" scope="session"/>
<br/>First page:<br/>
<x:forEach var="story" begin="0" end="3" select="$doc/rss/channel/item" > 
                      <x:out select="title/text()" /><br/>
</x:forEach>
<br/>Second page:<br/>
<x:forEach var="story" begin="4" end="${itemCount}" select="$doc/rss/channel/item" > 
                      <x:out select="title/text()" /><br/>
</x:forEach>

Open in new window

0
 
LVL 27

Expert Comment

by:rrz
ID: 33619640
Did that last code work for you ?
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 37136734
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question