// check if user is correctly logged
checkUser(request);
// get the form
UploadResourceForm sform = (UploadResourceForm)form;
// retrieve resources selected
String id = request.getSession().getAttribute("selectedResources")+"";
String path = null;
try {
ResourceXmlBean bean = Resources.getResourceXmlBean(servlet,id);
path = bean.getDirectory();
} catch( Exception e ) {
throw new ServletException(e);
}
String realPath = servlet.getServletContext().getRealPath("/");
File resources = new File(realPath,ResourceServlet.relativePath);
File tresources = new File(resources,path);
String on = sform.getFile().getFileName();
String ext = (on.indexOf(".")!=-1)?on.substring(on.indexOf(".")+1):"res";
String fileName = sform.getName()+"."+ext;
File ofile = new File( tresources, fileName );
FileOutputStream fos = new FileOutputStream(ofile);
fos.write(sform.getFile().getFileData());
// clean the form
sform.setName("");
// Forward to the next page
return (mapping.findForward("view"));
}