I have a servlet class that handles csv file uploads. I want the plugin to render a velocity template after the upload is complete to say that the file upload has been completed. Here is my code so far:
public class BulkUserCreatorToolServlet extends HttpServlet{
private final TemplateRenderer renderer;
private final WebResourceManager webResourceManager;
public BulkUserCreatorToolServlet(TemplateRenderer renderer, WebResourceManager webResourceManager){
this.renderer = renderer;
this.webResourceManager = webResourceManager;
}
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Create a factory for disk-based file items
DiskFileItemFactory factory = new DiskFileItemFactory();
// Configure a repository (to ensure a secure temp location is used)
ServletContext servletContext = this.getServletConfig().getServletContext();
File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir");
factory.setRepository(repository);
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
try{
//Parse the request to get file items
List<FileItem> fileItems = upload.parseRequest(request);
// Process the uploaded items
Iterator<FileItem> iter = fileItems.iterator();
while(iter.hasNext()){
//handle file
}
Map<String, Object> context = new HashMap<String, Object>();
context.put("testname", "testvalue");
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(renderer.render("plugin-key","response-page.vm", context));
}
catch(FileUploadException e){
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
}
}
Upon upload, Page Not Found always shows. What did I do wrong? Thank you
have you defined the servlet in the atlassian-plugin.xml?
You may want to post this on the Atlassian Development community for a faster response: https://community.developer.atlassian.com/
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.