You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.