I have searched a lot on this topic, but no questions/answers seem to provide what I am looking for. I apologize if the answer is floating around out there somewhere.
What I have are a series of utility JSPs that I have written, that I accessing via an index type JSP where I have a button form to go to the appropriate JSP. each one looks like this:
<form method="POST" action="delete.jsp">
<input type="submit" value="Delete" name="B2">
</form>
in my delete.jsp, I have another form that calls my servlet once the button is pressed, like this:
<form method="post" action="ModelServlet">
Select file to delete: <input type="file" name="dataFile" id="fileChooser" /><br />
<br /> <input type="submit" name="DELETE" value="Delete" />
</form>
When I press this 'delete' button, I get an "HTTP Status 405 - HTTP method POST is not supported by this URL" error. This leads me to believe there is some kind of mapping error, or something, preventing the utility JSP from finding my servlet. Any ideas on this? my servlet code is below:
my servlet that it is calling:
package com.model;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FileUtils;
public class ModelServlet extends HttpServlet {
protected void init(){}
protected void doPost(Model ourModel, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//check for which case we have: upload, delete, move, or copy
if (ServletFileUpload.isMultipartContent(request)){
//do upload stuff
performUpload(request,response);
}
else if (request.getParameter("DELETE") != null){
//do delete stuff
performDelete(request,response);
}
else if (request.getParameter("MOVE") != null){
//do move stuff
performMove(request,response);
}
else if (request.getParameter("COPY")!= null){
//do copy stuff
performCopy(request,response);
}
}
with methods defined for the functions below it.
Cheers, Joe