java - Size of RSS feed -
java - Size of RSS feed -
i'm using rome generate feed info in database.
in samples found, servlet extracts info database, , sends feed.
now, if database contains thousands of entries, how many entries should send?
protected void processrequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { seek { syndfeed feed = getfeed(request); string feedtype = request.getparameter("type"); feedtype = feedtype != null ? feedtype : defaulttype; feed.setfeedtype(feedtype); response.setcontenttype("application/xml; charset=utf-8"); syndfeedoutput output = new syndfeedoutput(); output.output(feed, response.getwriter()); } grab (feedexception ex) { string msg = "could not generate feed"; log(msg, ex); response.senderror(httpservletresponse.sc_internal_server_error, msg); } } protected syndfeed getfeed(httpservletrequest request) { // **** here query database posts, don't know how many // should fetch or should stop? *** list<post> posts = getposts(); syndfeed feed = new syndfeedimpl(); feed.settitle("my feed"); feed.setlink("http://myurl"); feed.setdescription("my desc"); // create feeds.each tutorial feed entry list<syndentry> entries = new arraylist<syndentry>(); (post post : posts) { syndentry entry = new syndentryimpl(); syndcontent description; string title = post.gettitle(); string link = post.getlink(); entry.settitle(title); entry.setlink(link); // create description of feed entry description = new syndcontentimpl(); description.settype("text/plain"); description.setvalue(post.getdesc()); entry.setdescription(description); entries.add(entry); } feed.setentries(entries); homecoming feed; }
there isn't single way rss clients support, recommend checking out rfc 5005 appendix b, you'll @ to the lowest degree have referenxe give clients. https://tools.ietf.org/html/rfc5005#appendix-b
so long default query shows latest (page length define) items, sorted descending, clients appear correct. clients need able page can implement standard.
java rss rome
Comments
Post a Comment