Solved

how to find size of the feeds at JSTL

Posted on 2010-09-04
14
195 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
  • 8
  • 4
14 Comments
 
LVL 27

Expert Comment

by:rrz
Comment Utility
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
Comment Utility
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
Comment Utility
or is there any specific method that i can find feed sizE?
0
 
LVL 27

Expert Comment

by:rrz
Comment Utility
>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
Comment Utility
       <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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 27

Expert Comment

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

Author Comment

by:elaltaico
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Did that last code work for you ?
0
 
LVL 26

Expert Comment

by:mrcoffee365
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
stringclean challenge 26 54
computer science syllabus 3 52
word0 challenge 4 52
best (free) software to access postgres db (java) 1 17
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…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now