Package ch.entwine.weblounge.common.content

Examples of ch.entwine.weblounge.common.content.RenderException


        }

        // Did we find a suitable JSP?
        if (jsp == null) {
          response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
          throw new RenderException(this, "No suitable java server page found for " + renderer + " and language '" + language.getIdentifier() + "'");
        }

        // Check readability
        if (!jsp.canRead()) {
          response.sendError(HttpServletResponse.SC_FORBIDDEN);
          throw new RenderException(this, "Java server page at " + jsp + " cannot be read");
        }

        // No directory listings allowed
        if (!jsp.isFile()) {
          response.sendError(HttpServletResponse.SC_FORBIDDEN);
          throw new RenderException(this, "Java server page at " + jsp + " is not a file");
        }

        renderer = jsp.toURI().toURL();
      }

      // Prepare a request to site resources
      String servletPath = "/weblounge-sites/" + site.getIdentifier();
      String requestPath = renderer.getPath();
      requestPath = requestPath.substring(servletPath.length());
      requestPath = UrlUtils.concat(Site.BUNDLE_PATH, requestPath);
      SiteRequestWrapper siteRequest = new SiteRequestWrapper(request, requestPath, false);

      RequestDispatcher dispatcher = request.getRequestDispatcher(servletPath);
      if (dispatcher == null)
        throw new IllegalStateException("No dispatcher found for site '" + site + "'");

      // Finally serve the JSP
      logger.debug("Including jsp {}", renderer);
      dispatcher.include(siteRequest, response);
     
      response.getWriter().flush();
    } catch (IOException e) {
      logger.error("Exception while including jsp {}", renderer, e);
    } catch (Throwable t) {
      throw new RenderException(this, t);
    }
  }
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.content.RenderException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.