title="P4JSP FileView";

File View:

String path = request.getParameter("path"); if (null == path) { response.sendRedirect(response.encodeRedirectURL("index.jsp")); return; } FileEntry fent = new FileEntry(env, path); fent.sync(); out.print("File: "+Utils.formatDepotPath(path, "<A href=\"browse.jsp?path={0}\">{1}</A>", "<A href=\"file.jsp?path={0}\">{1}</A>",null, true)); out.print("#"+fent.getHeadRev()); out.print(" is an "); if (1 < fent.getHeadRev()) { out.print("<A href=\"diff.jsp?path="+URLEncoder.encode(fent.getDepotPath())+"&r1="+(fent.getHeadRev()-1)+"&r2="+fent.getHeadRev()+"\">"+fent.getHeadAction()+"</A>"); } else { out.print(fent.getHeadAction()); } out.print(" from change <A href=\"change.jsp?num="+fent.getHeadChange()+"\">"+fent.getHeadChange()+"</A>"); out.print("<HR/>"); if (fent.getHeadType().endsWith("text")) { String cmd[] = { "p4", "print", path }; String l, c; int lnum = 0; try { P4Process p = new P4Process(env); p.setRawMode(true); p.exec(cmd); out.print("<PRE class=\"diff\">"); while (null != (l = p.readLine())) { if (0 == lnum++) continue; if (0 == l.length()) { out.println(""); continue; } if (l.startsWith("text: ")) { out.println(Utils.HTMLEncode(l.substring(6))); } } out.print("</PRE>"); p.close(); } catch (Exception ex) { /* Ignored. */ } }