You have to override the method doPost(HttpServletRequest request, HttpServletResponse response) in your servlet
Main Topics
Browse All TopicsHi,
I have recently picked up JSP and servlet and I am facing some problems.
After I try hitting the submit button, I got error stating that "HTTP method POST is not supported by this URL". May I know how do I resolve this problem as I could not call the method.
Thank you.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
public class upLoadServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, FileUploadException, UploadException {
PrintWriter out = response.getWriter();
MultipartFormDataRequest multiPartRequest =
new MultipartFormDataRequest(r
Hashtable files = multiPartRequest.getFiles(
UploadFile userFile = (UploadFile)files.get("csv
CSVReader reader = new CSVReader(
new InputStreamReader(userFile
String[] columns;
while ((columns = reader.readNext()) != null) {
out.println("<tr><td>" + columns[0] + "</td>");
out.println("<td>" + columns[1] + "</td></tr>");
}
reader.close();
}
}
I have change it to
public class upLoadServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
PrintWriter out = response.getWriter();
MultipartFormDataRequest multiPartRequest = new MultipartFormDataRequest(r
Hashtable files = multiPartRequest.getFiles(
UploadFile userFile = (UploadFile) files.get("csvUpload");
CSVReader reader = new CSVReader(new InputStreamReader(userFile
String[] columns;
while ((columns = reader.readNext()) != null) {
out.println("<tr><td>" + columns[0] + "</td>");
out.println("<td>" + columns[1] + "</td></tr>");
}
reader.close();
} catch (UploadException ex) {
Logger.getLogger(upLoadSer
}
}
}
but now i'm getting
java.lang.ArrayIndexOutOfB
love.controller.upLoadServ
javax.servlet.http.HttpSer
javax.servlet.http.HttpSer
org.netbeans.modules.web.m
btw, is there any place where they have tutorial on how to upload files which is similar to this or the use of upload bean?
Have a look at this:
http://www.javazoom.net/jz
I understand. I would create another method to take care of further processing of the file (in our case saving to disk). This method could be called after the reading ends (after reader.close()) and can take as argument an array of bytes (userFile.getData()):
private void persist(byte[] fileContent) throws IOException {
// open a new file with the desired name and path
// write the fileContent
// close the file
}
try using commonsFile Upload
have a look at
http://www.experts-exchang
and i have my own article posted at
http://scribblejava.wordpr
Business Accounts
Answer for Membership
by: dravidnsrPosted on 2009-09-08 at 06:12:48ID: 25281466
can u post error stack !!