예제 #1
0
 /**
  * will serve the index page displaying all schemas managed by this application.
  *
  * @param response
  * @throws IOException
  */
 private void serveIndex(HttpServletResponse response) throws IOException {
   try {
     PrintWriter out = response.getWriter();
     if (viewContainer.getIndex() != null && !viewContainer.getIndex().isEmpty()) {
       out.println(viewContainer.getIndex()); // todo: add caching
     } else {
       out.write("no index available");
     }
   } catch (IOException e) {
     log.log(Level.WARNING, "error writing index page to response");
     throw e; // let higher level servlet code deal with it
   }
 }
예제 #2
0
 /**
  * Serve an individual page.
  *
  * @param path - the path of the page to serve.
  * @param response
  * @throws IOException
  */
 private void servePage(String path, HttpServletResponse response) throws IOException {
   try {
     PrintWriter out = response.getWriter();
     View view = viewContainer.getViews().get(path);
     if (view == null) {
       throw new NullPointerException("can't find view for path: " + path);
     }
     out.println(view.getView()); // todo: add caching
   } catch (IOException e) {
     log.log(Level.WARNING, "error writing view page to response");
     throw e; // let higher level servlet code deal with it
   } catch (NullPointerException e) {
     response.sendError(404, path + " not found");
   }
 }