if (req.getParameterValues("docno") != null)
docno = Integer.parseInt(req.getParameterValues("docno")[0]);
else if (req.getParameterValues("docid") != null)
docno = sForwardIndex.getDocno(req.getParameterValues("docid")[0]);
Indexable doc = null;
int i = 0;
for(i = 0; i < lastDocs.length; i++)
if(docno <= lastDocs[i]) {
doc = docForwardIndex[i].getDocument(docno);
break;
}
if (doc != null) {
LOG.info("fetched: " + doc.getDocid() + " = docno " + docno);
res.setContentType(doc.getDisplayContentType());
PrintWriter out = res.getWriter();
out.print(doc.getContent().replaceAll("<\\s*/\\s*[bB][oO][dD][Yy]\\s*>", "<br><br><a href=\"/fetch_docno?docno=" + docno +
"\"> Fetch anchor text for docno: " + docno + "</a></body>"));
out.close();
} else {
throw new Exception();
}