Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to find size of the feeds at JSTL

Posted on 2010-09-04
14
Medium Priority
?
208 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 28

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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 28

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 28

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 28

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 28

Accepted Solution

by:
rrz earned 2000 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 28

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 28

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 28

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

Technology Partners: 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!

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

670 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