<%@ page session="false" contentType="text/html; charset=UTF-8" import="java.io.*" import="java.util.*" import="org.apache.nutch.searcher.*" import="org.apache.nutch.parse.ParseData" import="org.apache.nutch.metadata.Metadata" import="org.apache.hadoop.conf.Configuration" import="org.apache.nutch.util.NutchConfiguration" %><% Configuration nutchConf = NutchConfiguration.get(application); NutchBean bean = NutchBean.get(application, nutchConf); bean.LOG.info("cache request from " + request.getRemoteAddr()); Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")), Integer.parseInt(request.getParameter("id"))); HitDetails details = bean.getDetails(hit); String id = "idx=" + hit.getIndexNo() + "&id=" + hit.getIndexDocNo(); String language = ResourceBundle.getBundle("org.nutch.jsp.cached", request.getLocale()) .getLocale().getLanguage(); Metadata metaData = bean.getParseData(details).getContentMeta(); String content = null; String contentType = (String) metaData.get(Metadata.CONTENT_TYPE); if (contentType.startsWith("text/html")) { // FIXME : it's better to emit the original 'byte' sequence // with 'charset' set to the value of 'CharEncoding', // but I don't know how to emit 'byte sequence' in JSP. // out.getOutputStream().write(bean.getContent(details)) may work, // but I'm not sure. String encoding = (String) metaData.get("CharEncodingForConversion"); if (encoding != null) { try { content = new String(bean.getContent(details), encoding); } catch (UnsupportedEncodingException e) { // fallback to windows-1252 content = new String(bean.getContent(details), "windows-1252"); } } else content = new String(bean.getContent(details)); } %> <% out.flush(); %> <%@ taglib uri="http://jakarta.apache.org/taglibs/i18n" prefix="i18n" %>

"/>


<% if (contentType.startsWith("text/html")) {%> <% if (content != null && !content.equals("")) {%> <%= content %> <% } else { %> <% } %> <% } else { %> The cached content has mime type "<%=contentType%>", click this link to download it directly. <% } %>