Solved

how to find size of the feeds at JSTL

Posted on 2010-09-04
14
200 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
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.
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 …
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).

785 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