Package javax.servlet.http

Examples of javax.servlet.http.Part


    protected String upload(HttpServletRequest request, StringManager smClient)
            throws IOException, ServletException {
        String message = "";

        Part warPart = null;
        String filename = null;

        Collection<Part> parts = request.getParts();
        Iterator<Part> iter = parts.iterator();

        try {
            while (iter.hasNext()) {
                Part part = iter.next();
                if (part.getName().equals("deployWar") && warPart == null) {
                    warPart = part;
                } else {
                    part.delete();
                }
            }

            while (true) {
                if (warPart == null) {
View Full Code Here


    protected String upload(HttpServletRequest request, StringManager smClient) {
        String message = "";

        try {
            while (true) {
                Part warPart = request.getPart("deployWar");
                if (warPart == null) {
                    message = smClient.getString(
                            "htmlManagerServlet.deployUploadNoFile");
                    break;
                }
                String filename =
                    extractFilename(warPart.getHeader("Content-Disposition"));
                if (!filename.toLowerCase(Locale.ENGLISH).endsWith(".war")) {
                    message = smClient.getString(
                            "htmlManagerServlet.deployUploadNotWar", filename);
                    break;
                }
                // Get the filename if uploaded name includes a path
                if (filename.lastIndexOf('\\') >= 0) {
                    filename =
                        filename.substring(filename.lastIndexOf('\\') + 1);
                }
                if (filename.lastIndexOf('/') >= 0) {
                    filename =
                        filename.substring(filename.lastIndexOf('/') + 1);
                }

                // Identify the appBase of the owning Host of this Context
                // (if any)
                File file = new File(getAppBase(), filename);
                if (file.exists()) {
                    message = smClient.getString(
                            "htmlManagerServlet.deployUploadWarExists",
                            filename);
                    break;
                }
               
                ContextName cn = new ContextName(filename, true);
                String name = cn.getName();

                if ((host.findChild(name) != null) && !isDeployed(name)) {
                    message = smClient.getString(
                            "htmlManagerServlet.deployUploadInServerXml",
                            filename);
                    break;
                }

                if (!isServiced(name)) {
                    addServiced(name);
                    try {
                        warPart.write(file.getAbsolutePath());
                        // Perform new deployment
                        check(name);
                    } finally {
                        removeServiced(name);
                    }
View Full Code Here

  }


  public String getMultipartContentType(String paramOrFileName) {
    try {
      Part part = getPart(paramOrFileName);
      return (part != null ? part.getContentType() : null);
    }
    catch (Exception ex) {
      throw new MultipartException("Could not access multipart servlet request", ex);
    }
  }
View Full Code Here

    }
  }

  public HttpHeaders getMultipartHeaders(String paramOrFileName) {
    try {
      Part part = getPart(paramOrFileName);
      if (part != null) {
        HttpHeaders headers = new HttpHeaders();
        for (String headerName : part.getHeaderNames()) {
          headers.put(headerName, new ArrayList<String>(part.getHeaders(headerName)));
        }
        return headers;
      }
      else {
        return null;
View Full Code Here

  }


  public String getMultipartContentType(String paramOrFileName) {
    try {
      Part part = getPart(paramOrFileName);
      return (part != null ? part.getContentType() : null);
    }
    catch (Exception ex) {
      throw new MultipartException("Could not access multipart servlet request", ex);
    }
  }
View Full Code Here

    }
  }

  public HttpHeaders getMultipartHeaders(String paramOrFileName) {
    try {
      Part part = getPart(paramOrFileName);
      if (part != null) {
        HttpHeaders headers = new HttpHeaders();
        for (String headerName : part.getHeaderNames()) {
          headers.put(headerName, new ArrayList<String>(part.getHeaders(headerName)));
        }
        return headers;
      }
      else {
        return null;
View Full Code Here

            throw new FacesException(se);
        }
    }
   
    private static void decodeSimple(FacesContext context, FileUpload fileUpload, HttpServletRequest request) throws IOException, ServletException {
        Part part = request.getPart(fileUpload.getSimpleInputDecodeId(context));
       
        if(part != null) {
            fileUpload.setTransient(true);
            fileUpload.setSubmittedValue(new NativeUploadedFile(part));
        }
View Full Code Here

        }
  }
   
    private static void decodeAdvanced(FacesContext context, FileUpload fileUpload, HttpServletRequest request) throws IOException, ServletException {
        String clientId = fileUpload.getClientId(context);
        Part part = request.getPart(clientId);

        if(part != null) {
            fileUpload.setTransient(true);
            fileUpload.queueEvent(new FileUploadEvent(fileUpload, new NativeUploadedFile(part)));
        }
View Full Code Here

    public Part getPart(String name) throws IOException, IllegalStateException,
            ServletException {
        Collection<Part> c = getParts();
        Iterator<Part> iterator = c.iterator();
        while (iterator.hasNext()) {
            Part part = iterator.next();
            if (name.equals(part.getName())) {
                return part;
            }
        }
        return null;
    }
View Full Code Here

    public Part getPart(String name) throws IOException, IllegalStateException,
            ServletException {
        Collection<Part> c = getParts();
        Iterator<Part> iterator = c.iterator();
        while (iterator.hasNext()) {
            Part part = iterator.next();
            if (name.equals(part.getName())) {
                return part;
            }
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of javax.servlet.http.Part

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.