tags:

views:

24

answers:

1
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
       <%
       // decode source request:
 try {
      MultipartFormDataRequest multiPartRequest = new MultipartFormDataRequest(request);

    // get the files uploaded:
      Hashtable files = multiPartRequest.getFiles();

       ZipFile userFile = (ZipFile)files.get("bootstrap_file");

       if (! files.isEmpty()) {

       BootstrapDataManager bdm = new BootstrapDataManager(userFile);

       bdm.bootstrapStudent();
       bdm.bootstrapCourse();
       bdm.bootstrapSection();
       bdm.bootstrapBid();
       bdm.bootstrapCompletedCourses();
       bdm.bootstrapPreRequisite();
  }
       } catch (Exception error) {

    // set error flag in session:
    request.getSession().setAttribute("error", error);

    // throw its further to print in error-page:
    throw error;
  }


%>
    </body>
</html>

the BidDataManager takes in a ZipFile object in its constructor and i want to know how to convert an UploadFile object to a ZipFile object in order to pass it as a parameter..

A: 

There must be a method which returns an InputStream so that you can write it to FileOutputStream yourself like uploadFile.getInputStream(), or a method which takes a File like uploadFile.write(file).

Either way, you need to end up with a File so that you can pass it to the constructor of ZipFile. You can if necessary make use of File#createTempFile() to make it a TEMP file so that you don't need to worry about cleanup.

Regardless, a JSP is the wrong place for this job. I recommend to learn servlets before it's too late.

BalusC