Problem in enctype="multipart/form-data" in JSP

Ads
 

Problem in enctype="multipart/form-data" in JSP

im using a page which is in JSP. i have some text boxes and one upload button. i want to load the file itself when i click the submit button. im using enctype="multipart/form-data" in this form. i also using the commons-fileupload-1.2.2.jar file for getting the uploaded value. but the problem is the uploaded file is not stored in the prefered folder. i printed the path it shows correctly.

here the code,

the form is post method, and enctype="multipart/form-data"

here the code,

boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (!isMultipart) { out.print("No multipart");

} else {

      FileItemFactory factory = new DiskFileItemFactory();
      ServletFileUpload upload = new ServletFileUpload(factory);
      List items = null;

      try {

         items = upload.parseRequest(request);

         } catch (FileUploadException e) {

             e.printStackTrace();
          }
          Iterator itr = items.iterator();

          while (itr.hasNext()) 
          {
              FileItem item = (FileItem) itr.next();

              if (!item.isFormField()) {
                                    try {

                      String itemName = item.getName();
                      File savedFile = new File(config.getServletContext().getRealPath("/")+"emp_image\image\"+itemName);


                     item.write( savedFile);
                       out.print("<br>"+savedFile);    
                  } catch (Exception e) {

                      e.printStackTrace();
                  }



              } else {

                     String name = item.getFieldName();
              String value = item.getString();
                       }

the savedFile prints the path. and i also created the required folders. but the uploaded image is not present in the folder.

Help me to solve this problem.

View Answers

Ads









Related Tutorials/Questions & Answers:
Problem in enctype="multipart/form-data" in JSP
Problem in enctype="multipart/form-data" in JSP  im using a page... the file itself when i click the submit button. im using enctype="multipart/form-data... is post method, and enctype="multipart/form-data" here the code, boolean
Problem in enctype=
the submit button. im using enctype="multipart/form-data" in this form. i also using..., and enctype="multipart/form-data" here the code, boolean isMultipart...Problem in enctype=  im using a page which is in JSP. i have some
Advertisements
How to upload image to server in j2me by multipart/form-data?
How to upload image to server in j2me by multipart/form-data?  Hi, I...: Processing of ``multipart/form- data request failed. Stream ended unexpectedly...(imgData); conn.setRequestProperty("Content-Type", "multipart/form-data
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table... in advance.   1)form.html: <html> <form method="post
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table... in advance.   1)form.html: <html> <form method="post
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table... in advance.   1)form.html: <html> <form method="post
Jsp problem
Jsp problem  Hello friends.I want to share my jsp problem.I want to show all of my database(mysql) tables except two(user,manufacturer) in a jsp page.plssss help me
jsp problem
jsp problem  problem:::::::: On JSP form ,when i insert data in text... and get assign to other field on that form........ when data is assign to other field on that form at that time firstly inserted data is not present on that form
jsp problem
jsp problem  Hello Friends, I want to show one page for 5 seconds and after that i want to redirect the page to another URL
jsp problem
jsp problem  Hi every one plz give me answer for below question ASAP I created one JSP(used pre defined javascript in jsp to get rtf format in browser) which creats RTF Format in browser to enter data. MY question is after i
jsp reload current page problem
jsp reload current page problem  Hi, i am facing problem while reloading the JSP page
jsp reload current page problem
jsp reload current page problem  Hi, i am facing problem while reloading the JSP page
JSP code problem - JSP-Servlet
JSP code problem  HI.. I have a DB2 stored procedure wich return a result set. I have made a report basing on this procedure using Crystal Reports. How to pass parameters to this procedure with java code in a JSP page
Radio Button Problem in jsp.
Radio Button Problem in jsp.  I have a small doubt in my application... for each row as i got data from the database using iterator tag,but when i..." cellspacing="0" width="95%"> <s:form theme="simple" name="startTestForm" >
Statistical charts in JSP - problem
Statistical charts in JSP - problem  hey! i get this error when i run... org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred... An error occurred at line: 11 in the jsp file: /BarChart.jsp
JSP run problem
JSP run problem  type Exception report message description... this request. exception org.apache.jasper.JasperException: Exception in JSP...) root cause java.lang.NullPointerException org.apache.jsp.bb_jsp
jsp and bean problem
jsp and bean problem  Hi i have the following jsp code... Can you plz help me in separating the code to bean? I'm new to bean and need it for my...; String v_Cout; String v_Tot; String v_codeProduit; %> <form
Problem in record viewing in jsp - JSP-Servlet
Problem in record viewing in jsp  hai i have developed the application using jsp,servlets in eclipse ide i have to insert,delete,update and view . no problem all are working but in view part alone some problem i dont know what
problem in record viewing in jsp - JSP-Servlet
problem in record viewing in jsp  hai i send the code can you please find where is the problem it is not showing any error but i cannot able to view the record after eclipse ide is closed and reopen it i have used the jsp
problem in jsp using ms-access
problem in jsp using ms-access  after starting server(tomcat) wen v...;Control Panel>>Administrative Tools>>data sources. 2)Click Add button... the driver, click finish button. 4)Then give Data Source Name and click ok button. 5
JSP - Problem of displaying result at webpage
JSP - Problem of displaying result at webpage  Can anyone please help to solve my problem below. My webpage has problem in displaying result position...; <form method="post"> <table border="1" width="100
Java Servlet Problem - JSP-Servlet
method. Please help!!  Hi friend, Please explain problem in details for complete solution and send code the where are you problem. Thanks
problem at the time of execution - JSP-Servlet
problem at the time of execution  when i was running web applications the exception i.e 404 resource is not available what it means and where it occures what is the solution   Hi Friend, This error occurs when
problem on jsp, inserting data into table(mysql).
problem on jsp, inserting data into table(mysql).  hello friends, I have a problem in jsp.I want to insert data, which is given by user through... is in mysql.I want to use placeholder("?") to insert data into table.Plsssss help
Jsp/java-script, spring combination problem
Jsp/java-script, spring combination problem   Hi Friends....... I am developing one application using jsp,spring,java script,hibernate,Pojo There is one Jsp form on that I want data as location and ward wise; There is two
problem of static in jsp page by multiple user access
problem of static in jsp page by multiple user access  hi , i am continuing my online exam project,but i have a Singleton class which i am invoking from my jsp page , ths page can access by more number of users .every user
Jsp Image Display
;BODY> <FORM ENCTYPE="multipart/form-data" ACTION="upload.jsp" METHOD...;&(contentType.indexOf("multipart/form-data") >= 0)){ DataInputStream...Jsp Image Display  Hi,i need to display image in a Box like
Having problem with image upload....
upload form to the user</TITLE></HEAD> <BODY> <FORM ENCTYPE="multipart/form-data" ACTION="upload.jsp" METHOD=POST> <br><br>.../form-data") >= 0)){ DataInputStream in = new DataInputStream
uploading problem
form to the user</TITLE></HEAD> <BODY> <FORM ENCTYPE="multipart/form-data" ACTION="upload.jsp" METHOD=POST> <br><br><...uploading problem  i use glassfish server.. using netbeans for jsp
Uploading image using jsp
;FORM ENCTYPE="multipart/form-data" ACTION="upload.jsp" METHOD=POST> <br>...(); if((contentType != null)&&(contentType.indexOf("multipart/form-data") >= 0...Uploading image using jsp  how to upload image using jsp. Already i
Struts2...problem in JSP..unable to get the values for menuTitle!!!
Struts2...problem in JSP..unable to get the values for menuTitle!!!  ......n m fairly new in this framework.. there is some problem in this project...my Jsp is displaying the menuId from database but not the menuTitle...where as its

Ads