Package com.oreilly.servlet

Examples of com.oreilly.servlet.MultipartRequest


      }
       
      // Construct a MultipartRequest to help read the information.
      // Pass in the request, a directory to save files to, and the
      // maximum POST size we should attempt to handle.
      MultipartRequest multipartrequest =
      new MultipartRequest( request, stringWorkingDirectory, 5 * 1024 * 1024 );
     
      // Getting all file names from the request
      Enumeration files = multipartrequest.getFileNames();
     
      // Every received file will be converted to the specified type
      while (files.hasMoreElements()) {
        // Getting the name from the element
        String stringName = (String)files.nextElement();
       
        // Getting the filename from the request
        String stringFilename =
        multipartrequest.getFilesystemName( stringName );
       
        // Converting the given file on the server to the specified type and
        // append a special extension
        String stringConvertedFile = this.convertDocument(
        stringWorkingDirectory + stringFilename,
        multipartrequest.getParameter( "converttype" ),
        multipartrequest.getParameter( "extension" ) );

        // Constructing the multi part response to the client
        MultipartResponse multipartresponse = new MultipartResponse(
        response );
       
        // Is the convert type HTML?
        if ( ( multipartrequest.getParameter( "converttype" ).equals(
        "swriter: HTML (StarWriter)" ) )
        || ( multipartrequest.getParameter( "converttype" ).equals(
        "scalc: HTML (StarCalc)" ) ) ) {
          // Setting the content type of the response being sent to the client
          // to text
          multipartresponse.startResponse( "text/html" );
        } else {
View Full Code Here


            }
       
            // Construct a MultipartRequest to help read the information.
            // Pass in the request, a directory to save files to, and the
            // maximum POST size we should attempt to handle.
            MultipartRequest multipartrequest =
                new MultipartRequest( request, stringWorkingDirectory, 5 * 1024 * 1024 );
           
            // Getting all file names from the request
            Enumeration files = multipartrequest.getFileNames();
           
            // Every received file will be converted to the specified type
            while (files.hasMoreElements()) {
                // Getting the name from the element
                String stringName = (String)files.nextElement();
       
                // Getting the filename from the request
                String stringFilename =
                    multipartrequest.getFilesystemName( stringName );
               
                // Converting the given file on the server to the specified type and
                // append a special extension
                File cleanupFile = null;
                String stringSourceFile = stringWorkingDirectory + stringFilename;
               
                try {
                    String stringConvertedFile = convertDocument(stringSourceFile,
                        multipartrequest.getParameter( "converttype" ),
                        multipartrequest.getParameter( "extension" ));
                   
                    String shortFileName = stringConvertedFile.substring(
                        stringConvertedFile.lastIndexOf('/') + 1);

                    // Set the response header
                    // Set the filename, is used when the file will be saved (problem with mozilla)
                    response.addHeader( "Content-Disposition",
                                        "attachment; filename=" + shortFileName);
               
                    // Constructing the multi part response to the client
                    MultipartResponse multipartresponse = new MultipartResponse(response);
               
                    // Is the convert type HTML?
                    if ( ( multipartrequest.getParameter( "converttype" ).equals(
                               "swriter: HTML (StarWriter)" ) )
                         || ( multipartrequest.getParameter( "converttype" ).equals(
                                  "scalc: HTML (StarCalc)" ) ) ) {
                        // Setting the content type of the response being sent to the client
                        // to text
                        multipartresponse.startResponse( "text/html" );
                    } else {
View Full Code Here

            }
       
            // Construct a MultipartRequest to help read the information.
            // Pass in the request, a directory to save files to, and the
            // maximum POST size we should attempt to handle.
            MultipartRequest multipartrequest =
                new MultipartRequest( request, stringWorkingDirectory, 5 * 1024 * 1024 );
           
            // Getting all file names from the request
            Enumeration files = multipartrequest.getFileNames();
           
            // Every received file will be converted to the specified type
            while (files.hasMoreElements()) {
                // Getting the name from the element
                String stringName = (String)files.nextElement();
       
                // Getting the filename from the request
                String stringFilename =
                    multipartrequest.getFilesystemName( stringName );
               
                // Converting the given file on the server to the specified type and
                // append a special extension
                File cleanupFile = null;
                String stringSourceFile = stringWorkingDirectory + stringFilename;
               
                try {
                    String stringConvertedFile = convertDocument(stringSourceFile,
                        multipartrequest.getParameter( "converttype" ),
                        multipartrequest.getParameter( "extension" ));
                   
                    String shortFileName = stringConvertedFile.substring(
                        stringConvertedFile.lastIndexOf('/') + 1);

                    // Set the response header
                    // Set the filename, is used when the file will be saved (problem with mozilla)
                    response.addHeader( "Content-Disposition",
                                        "attachment; filename=" + shortFileName);
               
                    // Constructing the multi part response to the client
                    MultipartResponse multipartresponse = new MultipartResponse(response);
               
                    // Is the convert type HTML?
                    if ( ( multipartrequest.getParameter( "converttype" ).equals(
                               "swriter: HTML (StarWriter)" ) )
                         || ( multipartrequest.getParameter( "converttype" ).equals(
                                  "scalc: HTML (StarCalc)" ) ) ) {
                        // Setting the content type of the response being sent to the client
                        // to text
                        multipartresponse.startResponse( "text/html" );
                    } else {
View Full Code Here

        {
     
                            User u = (User) session.getAttribute("user");
                            Auction auction = new Auction();

        MultipartRequest multi = new MultipartRequest(request, "/home/buzz/NetBeansProjects/bweb/web/images/");

                                auction.setProduct(multi.getParameter("newProduct"));

                                auction.setCatId(new Integer(multi.getParameter("newCat")));

                                File f = multi.getFile("newImage");

                                String fileName = multi.getFilesystemName("newImage");

        auction.setPhoto(fileName);

                                auction.setStartingPrice(new Float (multi.getParameter("newStartingPrice")));
        auction.setLastPrice(new Float (multi.getParameter("newStartingPrice")));
                                auction.setMinPrice( new Float (multi.getParameter("newMinPrice")));

                                Integer duration,i = new Integer(multi.getParameter("newDuration"));
                                if(i == 1) duration = 4;
                                else if(i == 2) duration = 6;
                                else duration = 10;

                                Calendar cal = Calendar.getInstance();
                                cal.add(Calendar.DAY_OF_YEAR, duration );
                                Long e = (cal.getTimeInMillis());
                                java.sql.Date expire = new java.sql.Date(e);
                                auction.setExpire(expire);

                                auction.setShipping(multi.getParameter("newShip"));

                                auction.setUserId(u.getId());
                                auction.setLastPrice(null);
                                auction.setLastUserId(null);
                                auction.setDescription(multi.getParameter("newDesc"));

                                auction.save();
                                response.sendRedirect(request.getContextPath());
          }
}
View Full Code Here

                if(servletPath.equals("/feedbacks/save")) {
      if(session.getAttribute("user") != null) {

                           Feedback feedback = new Feedback();

         MultipartRequest multi = new MultipartRequest(request, "/home/buzz/NetBeansProjects/bweb/web/images/");

                           feedback.setFromId(new Integer(multi.getParameter("newFromUser")));
                           feedback.setToId(new Integer(multi.getParameter("newToUser")));

                           String mode = multi.getParameter("commMode");

                           if(mode.equals("text")) {
                                feedback.setText(multi.getParameter("newTextComm"));
                           }
                           else if(mode.equals("file")) {

                               File f = multi.getFile("newFileComm");

                               if( f != null ) {
                                    InputStream in = new FileInputStream(f);
                               try {


                                           BufferedReader reader = new BufferedReader(new InputStreamReader(in));
                                           String line = null;
                                           while ((line = reader.readLine()) != null) {

                                           comment += line;

                                           }
                                    } catch (IOException e) {

                                    } finally {

                                        if (in != null) in.close();
                                    }
                               }
                           feedback.setText(comment);
                           }
                          feedback.setScore(new Integer(multi.getParameter("newScore")));
                          feedback.save();
                        }
                }

                response.sendRedirect(request.getContextPath());
View Full Code Here

                if(servletPath.equals("/admin/feedbacks/save")) {
      if(session.getAttribute("admin") != null && session.getAttribute("admin").equals("true")) {

                           Feedback feedback = new Feedback();

         MultipartRequest multi = new MultipartRequest(request, "/home/buzz/NetBeansProjects/bweb/web/images/");

                           feedback.setFromId(new Integer(multi.getParameter("newFromUser")));
                           feedback.setToId(new Integer(multi.getParameter("newToUser")));

                           String mode = multi.getParameter("commMode");

                           if(mode.equals("text")) {
                                feedback.setText(multi.getParameter("newTextComm"));
                           }
                           else if(mode.equals("file")) {

                               File f = multi.getFile("newFileComm");

                               if( f != null ) {
                                    InputStream in = new FileInputStream(f);
                               try {


                                           BufferedReader reader = new BufferedReader(new InputStreamReader(in));
                                           String line = null;
                                           while ((line = reader.readLine()) != null) {
                                   
                                           comment += line;
                                   
                                           }
                                    } catch (IOException e) {
                                      
                                    } finally {
                                   
                                        if (in != null) in.close();
                                    }
                               }
                           feedback.setText(comment);
                           }
                          feedback.setScore(new Integer(multi.getParameter("newScore")));
                          feedback.save();
                        }
                }
                else if(servletPath.equals("/admin/feedbacks/update")) {
      if(session.getAttribute("admin") != null && session.getAttribute("admin").equals("true")) {

                           Feedback feedback = new Feedback();

         MultipartRequest multi = new MultipartRequest(request, "/home/buzz/NetBeansProjects/bweb/web/images/");

                           feedback.setId(new Integer(multi.getParameter("editId")));
                           feedback.setFromId(new Integer(multi.getParameter("editFromUser")));
                           feedback.setToId(new Integer(multi.getParameter("editToUser")));

                           String mode = multi.getParameter("commMode");

                           if(mode.equals("text")) {
                                feedback.setText(multi.getParameter("editTextComm"));
                           }
                           else if(mode.equals("file")) {

                               File f = multi.getFile("editFileComm");

                               if( f != null ) {

                                   InputStream in = new FileInputStream(f);

                                    try {


                                           BufferedReader reader = new BufferedReader(new InputStreamReader(in));
                                           String line = null;
                                           while ((line = reader.readLine()) != null) {

                                           comment += line;

                                           }
                                    } catch (IOException e) {

                                    } finally {

                                        if (in != null) in.close();
                                    }
                               }
                           feedback.setText(comment);
                           }
                          feedback.setScore(new Integer(multi.getParameter("editScore")));
                          feedback.update();
                        }
                }

                response.sendRedirect(request.getContextPath() + "/admin/feedbacks");
View Full Code Here

      }
       
      // Construct a MultipartRequest to help read the information.
      // Pass in the request, a directory to save files to, and the
      // maximum POST size we should attempt to handle.
      MultipartRequest multipartrequest =
      new MultipartRequest( request, stringWorkingDirectory, 5 * 1024 * 1024 );
     
      // Getting all file names from the request
      Enumeration files = multipartrequest.getFileNames();
     
      // Every received file will be converted to the specified type
      while (files.hasMoreElements()) {
        // Getting the name from the element
        String stringName = (String)files.nextElement();
       
        // Getting the filename from the request
        String stringFilename =
        multipartrequest.getFilesystemName( stringName );
       
        // Converting the given file on the server to the specified type and
        // append a special extension
        String stringConvertedFile = this.convertDocument(
        stringWorkingDirectory + stringFilename,
        multipartrequest.getParameter( "converttype" ),
        multipartrequest.getParameter( "extension" ) );

        // Constructing the multi part response to the client
        MultipartResponse multipartresponse = new MultipartResponse(
        response );
       
        // Is the convert type HTML?
        if ( ( multipartrequest.getParameter( "converttype" ).equals(
        "swriter: HTML (StarWriter)" ) )
        || ( multipartrequest.getParameter( "converttype" ).equals(
        "scalc: HTML (StarCalc)" ) ) ) {
          // Setting the content type of the response being sent to the client
          // to text
          multipartresponse.startResponse( "text/html" );
        } else {
View Full Code Here

                    throw new RuntimeException("Failed to create directory " + workingDir.getAbsolutePath());
                }

                try
                {
                    MultipartRequest req = new MultipartRequest(request.raw(), workingDir.getAbsolutePath(), Integer.MAX_VALUE);                   
                    String configString = makeConfigFileForJavaGrader(req, workingDir);
                    SimpleFileIO.writeStringToTextFile(configString, workingDir.getAbsolutePath() + File.separator + "config.txt");                   

                    //run automark
                    JavaGraderDriver agm = new JavaGraderDriver();
View Full Code Here

    public void build(HttpServletRequest request, File tempDir, long maxPostSize)
            throws IOException, FileUploadLimitExceededException {

        try {
            this.charset = request.getCharacterEncoding();
            this.multipart = new MultipartRequest(request,
                                                  tempDir.getAbsolutePath(),
                                                  (int) maxPostSize,
                                                  this.charset);
        }
        catch (IOException ioe) {
View Full Code Here

                    throw new RuntimeException("Failed to create directory " + workingDir.getAbsolutePath());
                }

                try
                {
                    MultipartRequest req = new MultipartRequest(request.raw(), workingDir.getAbsolutePath());                   
                    String configString = makeConfigFileForJavaGrader(req, workingDir);
                    SimpleFileIO.writeStringToTextFile(configString, workingDir.getAbsolutePath() + File.separator + "config.txt");                   

                    //run automark
                    JavaGraderDriver agm = new JavaGraderDriver();
View Full Code Here

TOP

Related Classes of com.oreilly.servlet.MultipartRequest

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.