Package javax.servlet.http

Examples of javax.servlet.http.HttpServletResponse


  public void destroy() {
  }

  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException {
    if (response instanceof HttpServletResponse) {
      HttpServletResponse httpResponse = (HttpServletResponse) response;
      httpResponse.sendError(404);
    }
  }
View Full Code Here


   * @param ureq
   * @param renderOnly
   */
  public void dispatchRequest(UserRequest ureq, boolean renderOnly) {
    HttpServletRequest request = ureq.getHttpReq();
    HttpServletResponse response = ureq.getHttpResp();
    String timestampID = ureq.getTimestampID();
    String componentID = ureq.getComponentID();
    //int browserT = timestampID == null? 0 : Integer.parseInt(timestampID);

    // case windowId timestamp componentId
View Full Code Here

      target.doFilter(servletRequest, servletResponse);
      return;
    }

    HttpServletRequest request = (HttpServletRequest) servletRequest;
    HttpServletResponse response = (HttpServletResponse) servletResponse;
    Tracing.setUreq(request);

    boolean success = false;
    try {
      // execute other filters or request
View Full Code Here

 
    public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
      Date now = new Date();
      HttpServletRequest httpRequest = (HttpServletRequest)request;
        HttpServletResponse httpResponse = (HttpServletResponse)response;
        String url = httpRequest.getServletPath();
        boolean processed = false;
        if (url.equals(PLUGIN_CRON_URL)) {
          getBusiness().getPluginBusiness().cronSchedule(now);
        processed = true;
View Full Code Here

    public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
      VosaoContext ctx = VosaoContext.getInstance();
      ctx.setSkipURLs(skipURLs);
      HttpServletRequest httpRequest = (HttpServletRequest)request;
        HttpServletResponse httpResponse = (HttpServletResponse)response;
        String url = httpRequest.getServletPath();
        if (url.startsWith("/_ah/plugin")) {
          if (processPluginServlet(request, response)) {
            return;
          }
        }
        if (ctx.isSkipUrl(url)) {
            chain.doFilter(request, response);
            return;
        }
        if (!isLoggedIn(httpRequest) && servedFromCache(url, httpResponse)) {
          return;
        }
        SeoUrlEntity seoUrl = getDao().getSeoUrlDao().getByFrom(url);
        if (seoUrl != null) {
          httpResponse.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
          httpResponse.setHeader("Location", seoUrl.getToLink());
          httpResponse.setHeader("Connection", "close");
            return;
        }
      try {
        if (getDao().getGroupDao().getGuestsGroup() == null) {
          httpResponse.sendRedirect("/setup");
          return;
        }
        PageEntity page = getPage(url, httpRequest);
        if (page != null) {
          renderPage(httpRequest, httpResponse, page, url);
          return;
        }
        if (url.equals("/")) {
          showNoApprovedContent(httpResponse);
          return;
        }
        ConfigEntity config = ctx.getConfig();
        if (!StringUtils.isEmpty(config.getSite404Url())) {
            page = getPage(config.getSite404Url(), httpRequest);
            if (page != null) {
              renderPage(httpRequest, httpResponse, page, url);
            }
        }
        httpResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
      }
      catch (AccessDeniedException e) {
      HttpSession session = httpRequest.getSession(true);
            String userEmail = (String)session.getAttribute(
                AuthenticationFilter.USER_SESSION_ATTR);
            UserEntity user = getDao().getUserDao().getByEmail(userEmail);
        ConfigEntity config = ctx.getConfig();
        if (user != null) {
          renderMessage(httpResponse, Messages.get("access_denied_page"));
          return;
        }
        if (StringUtils.isEmpty(config.getSiteUserLoginUrl())) {
          renderMessage(httpResponse, Messages.get("login_not_configured"));
          return;
        }
         session.setAttribute(AuthenticationFilter.ORIGINAL_VIEW_KEY,
             httpRequest.getRequestURI());
         httpResponse.sendRedirect(httpRequest.getContextPath()
             + config.getSiteUserLoginUrl());
      }
    }
View Full Code Here

    }
 
    public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
      HttpServletRequest httpRequest = (HttpServletRequest)request;
        HttpServletResponse httpResponse = (HttpServletResponse)response;
        String url = httpRequest.getServletPath();
        if (url.equals(UPDATE_URL)) {
          String msg = "<h2>Vosao CMS " + SetupBean.FULLVERSION + " Update</h2>";
          try {
            UpdateManager updateManager = new UpdateManager(getBusiness());
View Full Code Here

   private static ThreadLocal<CometEvent> cometEvent = new ThreadLocal<CometEvent>();

   public void event(CometEvent event) throws IOException, ServletException
   {
      HttpServletRequest request = event.getHttpServletRequest();
      HttpServletResponse response = event.getHttpServletResponse();
      if (event.getEventType() == CometEvent.EventType.BEGIN)
      {
         cometEvent.set(event);
         try
         {
View Full Code Here

   private static ThreadLocal<HttpEvent> cometEvent = new ThreadLocal<HttpEvent>();

   public void event(HttpEvent event) throws IOException, ServletException
   {
      HttpServletRequest request = event.getHttpServletRequest();
      HttpServletResponse response = event.getHttpServletResponse();
      switch (event.getType())
      {
         case BEGIN:
         {
            try
View Full Code Here

     * @see javax.servlet.Servlet#service(javax.servlet.ServletRequest,
     *      javax.servlet.ServletResponse)
     */
    public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
        HttpServletRequest req = (HttpServletRequest) request;
        HttpServletResponse res = (HttpServletResponse) response;
        debugRequest(req);
        DAVTransaction transaction = null;
        try {
            transaction = new DAVTransaction(req, res);
            DAVProcessor processor = null;
            try {
                processor = DAVServlet.getDAVProcessor(req);
            } catch (CoreException e) {
                ActionMessages mesgs = (ActionMessages) request.getAttribute(Globals.ERROR_KEY);
                if (mesgs == null) {
                    mesgs = new ActionMessages();
                    request.setAttribute(Globals.ERROR_KEY, mesgs);
                }
                mesgs.add(Globals.MESSAGE_KEY, e.getBundleActionMessage());
                return;
            } catch (Exception e1) {
                throw new IOException(e1.getMessage());
            }

            /**
             * LDP - JB I have removed the authentication code here and instead
             * placed in DAVTransaction. This allows the transaction to
             * correctly obtain sessionInfo through WEBDav.
             */
            /* Mark our presence */
            res.setHeader("Server", this.context.getServerInfo() + " WebDAV");
            res.setHeader("MS-Author-Via", "DAV");
            res.setHeader("DAV", "1");

            /*
             * Get the current SessionInfo if possible, but do not request
             * authentication yet This is because the VFSResource that we want
             * is in a mount that does not require Adito authentication
             * (required for some ActiveX and Applet extensions).
             *
             * SessionInfo will be null if session can yet be determined
             */
            if (!transaction.attemptToAuthorize()) {
                return;
            }
            SessionInfo sessionInfo = transaction.getSessionInfo();

            // Timeout block is not needed if we have no session
            int timeoutId = sessionInfo == null ? -1 : LogonControllerFactory.getInstance().addSessionTimeoutBlock(
                transaction.getSessionInfo().getHttpSession(), "DAV Transaction");
            ;
            try {
                processor.process(transaction);
            } catch (DAVAuthenticationRequiredException dare) {
                /*
                 * If the session is temporary, then we are probably dealing
                 * with a client that doesn't support cookies. This means that
                 * secondary authentication that may be required for some mounts
                 * won't work as we cannot have two different sets of
                 * credentials without session tracking
                 */
                if (sessionInfo != null && sessionInfo.isTemporary()) {
                    throw new IOException("Mount requires further authentication. This cannot work "
                                    + "on WebDAV clients that do not support cookies.");
                } else {
                    throw dare;
                }

            } finally {
                if (timeoutId != -1)
                    LogonControllerFactory.getInstance().removeSessionTimeoutBlock(transaction.getSessionInfo().getHttpSession(),
                        timeoutId);
            }
        } catch (DAVRedirection redir) {
            String redirPath = "/fs" + redir.getLocation().getFullPath();
            req.getRequestDispatcher(redirPath).forward(req, res);
        } catch (DAVAuthenticationRequiredException e) {
            // We need to be able to authenticate the Adito session was
            // well
            // sendAuthorizationError(req, res, e.getMount().getMountString());
            sendAuthorizationError(req, res, e.getHttpRealm());
        } catch (DAVBundleActionMessageException ex) {
            log.error("Network Places Request Failed: " + req.getPathInfo(), ex);
            BundleActionMessage bam = ex.getBundleActionMessage();
            MessageResources mr = CoreUtil.getMessageResources(req.getSession(), bam.getBundle());
            // TODO locale
            String val = mr == null ? null : mr.getMessage(bam.getKey());
            res.sendError(DAVStatus.SC_INTERNAL_SERVER_ERROR, val == null ? (ex.getMessage() == null ? "No message supplied." : ex
                            .getMessage()) : val);
        } catch (DAVException ex) {
            res.setStatus(ex.getStatus());
        } catch (LockedException ex) {
            res.sendError(DAVStatus.SC_LOCKED, ex.getMessage());
        } catch (Throwable t) {
            log.error("Network Places Request Failed: " + req.getPathInfo(), t);
            res.sendError(DAVStatus.SC_INTERNAL_SERVER_ERROR, t.getMessage() == null ? "<null>" : t.getMessage());
        } finally {
            if (transaction != null && transaction.getSessionInfo() != null && transaction.getSessionInfo().isTemporary()) {
                transaction.getSessionInfo().getHttpSession().invalidate();
            }
        }
View Full Code Here

        }
      }
    }

    if (!authenticated) {
      HttpServletResponse response = context.getResponse();
      response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      response.setHeader("WWW-Authenticate", "Basic realm=\"" + _prefs.getTitle() + '"');
      String contentType = MimeTypes.guessContentType(context.getRequest());
      response.setContentType(contentType);
      try {
        Templates.message(context, contentType, 401);
      } catch(IOException e) {
        context.log().error("Error while writing '401 Unathorized' response", e);
      }
View Full Code Here

TOP

Related Classes of javax.servlet.http.HttpServletResponse

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.