source: apps/routerconsole/jsp/flags.jsp @ 35c9e99

Last change on this file since 35c9e99 was 35c9e99, checked in by zzz <zzz@…>, 11 years ago
  • Throw 403 instead of 404 from flags.jsp and viewstat.jsp so we don't render error.jsp
  • Property mode set to 100644
File size: 1.2 KB
Line 
1<%
2/*
3 * USE CAUTION WHEN EDITING
4 * Trailing whitespace OR NEWLINE on the last line will cause
5 * IllegalStateExceptions !!!
6 */
7
8/**
9 *  flags.jsp?c=de => icons/flags/de.png
10 *  with headers set so the browser caches.
11 */
12boolean rendered = false;
13String c = request.getParameter("c");
14if (c != null && c.length() > 0) {
15    java.io.OutputStream cout = response.getOutputStream();
16    response.setContentType("image/png");
17    response.setHeader("Cache-Control", "max-age=86400");  // cache for a day
18    String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath();
19    String file = "docs" + java.io.File.separatorChar + "icons" + java.io.File.separatorChar +
20                  "flags" + java.io.File.separatorChar + c + ".png";
21    try {
22        net.i2p.util.FileUtil.readFile(file, base, cout);
23        rendered = true;
24    } catch (java.io.IOException ioe) {}
25    if (rendered)
26        cout.close();
27}
28/*
29 *  Send a 403 instead of a 404, because the server sends error.jsp
30 *  for 404 errors, complete with the summary bar, which would be
31 *  a huge load for a page full of flags if the user didn't have the
32 *  flags directory for some reason.
33 */
34if (!rendered)
35    response.sendError(403, "Flag not found");
36%>
Note: See TracBrowser for help on using the repository browser.