@Override protected String adminShutdown() { stopNow(); return super.adminShutdown(); }
/** * Replace the tags in the HTML page with the given settings. * * @param page the HTML page * @param settings the settings * @return the converted page */ public static String parse(String page, Map<String, Object> settings) { PageParser block = new PageParser(page, settings, 0); return block.replaceTags(); }
@Override public String getURL() { updateURL(); return url; }
private String admin() { session.put("port", "" + server.getPort()); session.put("allowOthers", "" + server.getAllowOthers()); session.put("ssl", String.valueOf(server.getSSL())); session.put("sessions", server.getSessions()); return "admin.jsp"; }
/** * Create a session with a given connection. * * @param conn the connection * @return the URL of the web site to access this connection */ public String addSession(Connection conn) throws SQLException { WebSession session = createNewSession("local"); session.setShutdownServerOnDisconnect(); session.setConnection(conn); session.put("url", conn.getMetaData().getURL()); String s = (String) session.get("sessionId"); return url + "/frame.jsp?jsessionid=" + s; }
/** * Start the translation thread that reads the file once a second. * * @param translation the translation map * @return the name of the file to translate */ String startTranslate(Map<Object, Object> translation) { if (translateThread != null) { translateThread.stopNow(); } translateThread = new TranslateThread(translation); translateThread.setDaemon(true); translateThread.start(); return translateThread.getFileName(); }
private String getHistory() { int id = Integer.parseInt(attributes.getProperty("id")); String sql = session.getCommand(id); session.put("query", PageParser.escapeHtmlData(sql)); return "query.jsp"; }
/** * Save the current connection settings to the properties file. * * @return the file to open afterwards */ private String settingSave() { ConnectionInfo info = new ConnectionInfo(); info.name = attributes.getProperty("name", ""); info.driver = attributes.getProperty("driver", ""); info.url = attributes.getProperty("url", ""); info.user = attributes.getProperty("user", ""); server.updateSetting(info); attributes.put("setting", info.name); server.saveProperties(null); return "index.do"; }
private boolean allow() { if (server.getAllowOthers()) { return true; } try { return NetUtils.isLocalAddress(socket); } catch (UnknownHostException e) { server.traceError(e); return false; } }
private String adminStartTranslate() { Map<?, ?> p = Map.class.cast(session.map.get("text")); @SuppressWarnings("unchecked") Map<Object, Object> p2 = (Map<Object, Object>) p; String file = server.startTranslate(p2); session.put("translationFile", file); return "helpTranslate.jsp"; }
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { doGet(req, resp); }
/** * Convert data to HTML, but don't convert newlines and multiple spaces. * * @param s the data * @return the escaped html text */ static String escapeHtmlData(String s) { return escapeHtml(s, false); }
private void trace(String s) { server.trace(s); } }
/** * Stop the application and the server. * * @return the page to display */ protected String adminShutdown() { server.shutdown(); return "admin.jsp"; }
@Override public void destroy() { server.stop(); }
private String getAllowedFile(String requestedFile) { if (!allow()) { return "notAllowed.jsp"; } if (requestedFile.length() == 0) { return "index.do"; } return requestedFile; }
public void stopNow() { this.stopNow = true; try { join(); } catch (InterruptedException e) { // ignore } }
WebSession(WebServer server) { this.server = server; // This must be stored in the session rather than in the server. // Otherwise, one client could allow // saving history for others (insecure). this.commandHistory = server.getCommandHistoryList(); }
/** * Convert data to HTML, including newlines and multiple spaces. * * @param s the data * @return the escaped html text */ public static String escapeHtml(String s) { return escapeHtml(s, true); }
private void trace(String s) { server.trace(s); }