I have an upload routine which is working for servlets. Now I was trying to put this routine in a jsf managed bean like this:
public void uploadFile() throws IOException, ServletException{
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
Part filePart = request.getPart("item");
String filename = getFilename(filePart);
InputStream filecontent = filePart.getInputStream();
//persist the data here
}
when trying to run it on the server, of course there is the error message: "PWC4016: Request.getPart is called without multipart configuration. Either add a @MultipartConfig to the servlet, or a multipart-config element to web.xml"
But I don't know where to put this annotation, neither do I have the name of the jsf generated servlet of my managed bean so I can't put it into the web.xml neither. Is it generally a bad idea to put this routine into a managed bean or should I stick to the servlet variant?