jsp - Unable to upload a file using java -



jsp - Unable to upload a file using java -

i receving next error: java.lang.nosuchmethoderror: org/apache/commons/fileupload/servlet/servletfileupload.parserequest(lorg/apache/commons/fileupload/requestcontext;)ljava/util/list;

the below code.

inputstream inputstream = null; string griddatastr =""; string errormsg = ""; dtobject resultdto = new dtobject(); fileitem fileitem = null; //printwriter send json response printwriter out = response.getwriter(); // check have file upload request boolean ismultipart = servletfileupload.ismultipartcontent(request); if (!ismultipart) { return; } // create mill disk-based file items diskfileitemfactory mill = new diskfileitemfactory(); // sets size threshold beyond files written straight // disk. factory.setsizethreshold(max_memory_size); // sets directory used temporarily store files larger // configured size threshold. utilize temporary directory // java factory.setrepository(new file(system.getproperty("java.io.tmpdir"))); // constructs folder uploaded file stored string uploadfolder = getservletcontext().getrealpath("") + file.separator + destinationdir; // create new file upload handler servletfileupload upload = new servletfileupload(factory); // set overall request size constraint upload.setsizemax(max_request_size); try{ // parse request list items = upload.parserequest(request); //error occurs here iterator iter = items.iterator(); while (iter.hasnext()) { fileitem item = (fileitem) iter.next(); if (!item.isformfield()) { string filename = new file(item.getname()).getname(); string filepath = uploadfolder + file.separator + filename; file uploadedfile = new file(filepath); system.out.println(filepath); // saves file upload directory item.write(uploadedfile); } } // displays done.jsp page after upload finished getservletcontext().getrequestdispatcher("/blahblah.jsp").forward( request, response); }catch (exception e){ system.out.println("exception occured "+e); e.printstacktrace (); errormsg="error uploading file"; } system.out.println(">> in excelupload::dopost()::exit # errormsg - "+errormsg); if(errormsg!=null && errormsg!=""){ request.setattribute("errormsg", errormsg); }

i using commons.fileupload1.2.2.jar. using common.fileupload.1.2.1.jar , there same error, changed version still error persists. can please spot error?

java jsp servlets file-upload

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -