Hello,
I first used primefaces FileUpload component and it didn't work. Always gave "HTTP Error". So i thought there is some bug with this component and went to plain old JQuery and tried using uploadify. But still i get the same error. I am using Container Managed Security. Is this the reason for not working properly?
This is my script :-
$(document).ready(function(){
$('#photoInput').uploadify({
'script' : '/Blogger/fileUploadServlet',
'uploader' : './uploadify/uploadify.swf',
'cancelImg' : './uploadify/cancel.png',
'auto' : true
});
UPDATE
Response Headers:
X-Powered-By Servlet/3.0, JSF/2.0 Server GlassFish v3 Set-Cookie JSESSIONID=a23a36b147ac171f8abbf64406cd; Path=/Blogger Content-Type text/html;charset=UTF-8 Content-Length 1430 Date Thu, 29 Apr 2010 15:16:12 GMT
Request Headers
Host localhost:8080 User-Agent Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.6) Gecko/20091215 Ubuntu/9.10 (karmic) Firefox/3.5.6 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 300 Connection keep-alive Cookie username=laala; password=panchal; JSESSIONID=a029f59bed8ba0c22fb27a612bf2; treeForm:tree-hi=treeForm:tree:applications; JSESSIONID=962073f17f3d0ebb37536f789b90 Cache-Control max-age=0**
And this is my servlet which is never executed :-
package Servlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
@WebServlet(name = "fileUploadServlet", urlPatterns = {"/fileUploadServlet"})
public class fileUploadServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, FileUploadException {
PrintWriter out = response.getWriter();
try {
System.out.println("Executed!!");
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// Parse the request
List /* FileItem */ items = upload.parseRequest(request);
Iterator e = items.iterator();
while(e.hasNext()){
System.out.println(e.next().toString());
}
} finally {
out.close();
}
}
}
});