jsp - convert UploadFile object to a ZipFile object -
<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); // 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 further print in error-page: throw error; } %> </body> </html>
the biddatamanager takes in zipfile object in constructor , want know how convert uploadfile object zipfile object in order pass parameter..
there must method returns inputstream
can write fileoutputstream
uploadfile.getinputstream()
, or method takes file
uploadfile.write(file)
.
either way, need end file
can pass constructor of zipfile
. can if necessary make use of file#createtempfile()
make temp file don't need worry cleanup.
regardless, jsp wrong place job. recommend learn servlets before it's late.
Comments
Post a Comment