Package javax.servlet.http

Examples of javax.servlet.http.HttpServletResponse


        dispatcher.forward(request, response);
    }
   
    public void include(String path) throws ServletException, IOException {
        HttpServletRequest request = (HttpServletRequest) super.getVariable("request");
        HttpServletResponse response = (HttpServletResponse) super.getVariable("response");
        RequestDispatcher dispatcher = request.getRequestDispatcher(path);
        dispatcher.include(request, response);
    }
View Full Code Here


        RequestDispatcher dispatcher = request.getRequestDispatcher(path);
        dispatcher.include(request, response);
    }

    public void redirect(String location) throws IOException {
        HttpServletResponse response = (HttpServletResponse) super.getVariable("response");
        response.sendRedirect(location);
    }   
View Full Code Here

  }

  public void commence(final ServletRequest servletRequest, final ServletResponse servletResponse,
      final AuthenticationException ae) throws IOException, ServletException {
    final HttpServletRequest request = (HttpServletRequest) servletRequest;
    final HttpServletResponse response = (HttpServletResponse) servletResponse;
    if (null != ae && (ae instanceof UsernameNotFoundException)) {
      response.getWriter().append(String.valueOf(ae.getAuthentication().getPrincipal())).append(ae.getMessage());
    } else {
      final String encodedServiceUrl = CommonUtils.constructServiceUrl(request, response, null,
          config.getLocalServer(), config.getArtifactName(), config.isEncode());
      final String redirectUrl = CommonUtils.constructRedirectUrl(config.getLoginUrl(), "service",
          encodedServiceUrl, config.isRenew(), false);
      response.sendRedirect(redirectUrl);
    }
  }
View Full Code Here

      HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
      ((ServletRequestAware) action).setServletRequest(request);
    }

    if (action instanceof ServletResponseAware) {
      HttpServletResponse response = (HttpServletResponse) context.get(HTTP_RESPONSE);
      ((ServletResponseAware) action).setServletResponse(response);
    }

    return invocation.invoke();
  }
View Full Code Here

      context.put(Context.KEYS, get("keys"));
      context.put(Context.TITLES, get("titles"));
    }
    context.put(Context.EXTRACTOR, getPropertyExtractor());

    HttpServletResponse response = ServletActionContext.getResponse();
    Exporter exporter = buildExporter(context);
    exporter.getWriter().setOutputStream(response.getOutputStream());
    configExporter(exporter, context);
    if (format.equals(TransferFormats.XLS)) {
      response.setContentType("application/vnd.ms-excel;charset=GBK");
    } else {
      response.setContentType("application/x-msdownload");
    }
    response.setHeader(
        "Content-Disposition",
        "attachment;filename="
            + encodeAttachName(ServletActionContext.getRequest(), fileName + "." + format));
    // 进行输出
    exporter.setContext(context);
View Full Code Here

    // only accept HtmlCanvas typed parameter
    if (methodParameter.getParameterType() != HtmlCanvas.class)
      return UNRESOLVED;
   
    HttpServletRequest request = (HttpServletRequest)(webRequest.getNativeRequest());
    HttpServletResponse response = (HttpServletResponse)(webRequest.getNativeResponse());
        HtmlCanvas canvas = HtmlCanvasFactory.createCanvas(request,response,response.getWriter());
        PageContext context = canvas.getPageContext();
       
        boolean empty = true;
    if (this.shareSessionAttributes) {
        HttpSession session = request.getSession(false);
View Full Code Here

  public void doFilter(ServletRequest servletRequest,
      ServletResponse servletResponse, FilterChain chain)
      throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;
    HttpServletResponse response = (HttpServletResponse) servletResponse;

    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");

    String uri = request.getRequestURI();

    // Strip jsessionid from URI.
    int jsessionidIndex = uri.indexOf(";jsessionid=");
    if (jsessionidIndex != -1) {
      uri = uri.substring(0, jsessionidIndex);
    }

    // Process internal context prefix
    int tilde = uri.indexOf("~");
    if (tilde != -1) {
      String path = uri.substring(tilde + 1);
      response.sendRedirect(response.encodeRedirectURL(buildURI(
          request.getContextPath() + path, request.getQueryString())));
      return;
    }

    // Try to resolve node from URI (without context path).
    String nodePath = uri.substring(request.getContextPath().length());
    Node node = Nodes.getByPath(nodePath);

    // Process redirect rules
    if (node == null && !servlets.matcher(nodePath).matches()) {
      String sourceURI = buildURI(nodePath, request.getQueryString());
      String targetURI = rewriteURI(sourceURI);
      if (!targetURI.equals(sourceURI)) {
        if (targetURI.contains("://")) {
          response.sendRedirect(response.encodeRedirectURL(targetURI));
        } else {
          response.sendRedirect(response.encodeRedirectURL(request
              .getContextPath() + targetURI));
        }
        return;
      }
    }

    // Save "virtual" root node. Per default it is the absolute root of the
    // instance.
    // If a node with the server name exists, this node is used as virtual
    // root.
    if (request.getAttribute("Root") == null) {
      String server = Servlets.getServerName(request).replaceFirst(
          "www.", "");
      Node root = Nodes.getRoot() != null ? Nodes.getRoot().getChild(
          server) : null;
      if (root == null) {
        root = Nodes.getRoot();
      }
      request.setAttribute("Root", root);
      if (node != null && root.getParent() == node) {
        response.sendRedirect(response.encodeRedirectURL(request
            .getContextPath() + root.getPath()));
        return;
      }
    }

    // If no node is found, process filter chain.
    if (node == null) {
      chain.doFilter(request, response);
      return;
    }

    // Redirect if trailing slash is missing for containers.
    if (node.isContainer() && !uri.endsWith("/")) {
      response.sendRedirect(response.encodeRedirectURL(buildURI(
          uri + "/", request.getQueryString())));
    } else {
      // Set node into request scope and forward to dispatcher
      request.setAttribute(Node.class.getSimpleName(), node);
      request.setAttribute(Names.JEASE_SITE_DISPATCHER, dispatcher);
View Full Code Here

        // See whether we need to use a custom response (if we're inside a TTM
        // or TDM or macro nested body, we'll need to as then the current
        // FM environment writer is not identical to HTTP servlet response
        // writer.
        final Writer envOut = env.getOut();
        final HttpServletResponse wrappedResponse;
        if(envOut == response.getWriter()) {
            // Don't bother wrapping if environment's writer is same as
            // response writer
            wrappedResponse = response;
        }
View Full Code Here

                if ( portletName == null )
                {
                    throw new JspException( "No portlet to render" );
                }

                HttpServletResponse response = ( HttpServletResponse ) pageContext.getResponse(  );
                PortletApplication  container = getPortletContainer(  );
                PortletProxy        proxy = ( PortletProxy ) getPortletContainer(  ).getPortlet( portletName );
                PortletRequestImpl  req = new PortletRequestImpl( proxy, request, container.getPortletServiceFactory(  ) );
                PortletResponseImpl resp = new PortletResponseImpl( proxy, req, response );
               
View Full Code Here

  public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException,
      ServletException {
    boolean chainCalled = false;
    if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
      HttpServletRequest httpRequest = (HttpServletRequest) request;
      HttpServletResponse httpResponse = (HttpServletResponse) response;

      String requestUri = httpRequest.getRequestURI();

      if (!checkPrefixes(requestUri, skipPrefixes)) {
        String serverName = httpRequest.getServerName();
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.