• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTTP Status 405

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have run Upload File programs according to O'Reilly.They are successful in the office. But I meet problem at home.
The error message is as following.
The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL).
How can I solve it?
Thanks a lot.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You get that message if the servlet your URL addresses does not have a doPost method to handle POST.
So the servlet engine can find something with that URL but it is probably not the one you want. Exactly what URL are you using, which servlet engine, what did you install that is supposed to be handling the URL?
Bill
 
Sophia Choi
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, the servlet has only a doPost method. The engine is Tomcat 4.1.24.
It is same in my office. My problem is still having.
Code:
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String dir = ".";
try{
out.println("Upload Test start...");
//MultipartRequest multi = new MultipartRequest(req,".",5*1024*1024);
MultipartRequest multi = new MultipartRequest(req,dir,5*1024*1024);
out.println("123");
out.println("<html>");
out.println("<head><title>UploadTest</title></head>");
out.println("<body>");
out.println("<H1>UploadTest</h1>");
out.println("<h3>Params:</h3>");
out.println("<Pre>");
Enumeration params = multi.getParameterNames();
while(params.hasMoreElements()){
String name=(String)params.nextElement();
String value =multi.getParameter(name);
out.println(name + " = " + value);
}
out.println("</PRE>");
out.println("<h3>Files:</h3>");
out.println("<pre>");
Enumeration files=multi.getFileNames();
while(files.hasMoreElements()){
String name = (String)files.nextElement();
String filename = multi.getFilesystemName(name);
String type = multi.getContentType(name);
File f=multi.getFile(name);
out.println("name: "+name);
out.println("filename: "+filename);
out.println("type: "+ type);
if(f != null){
out.println("length: "+f.length());
out.println();
}
out.println("</pre>");
}
}
catch(Exception e){
out.println("<pre>");
e.printStackTrace(out);
out.println("<pre>");
}
out.println("</body></html>");
}
}
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
There are two ways by which this error can be solved ..
before that some questions
1. Are you calling this servlet from a form where u get the data through a html file .
2. what is the configuration of the IE at your place and at office.. are both IE version same
if after this also the error is not solved try using generic servlet and write the service method and try it .. may be it would solve the problem
also see that on tomcat r u getting any error message..
may be its problem with the tomcat settings also
also try putting try catch block in your code and use exception.printstacktrace...
this would help you to solve the problems
best luck
vijay shah
v.shah@portlog.com
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sophia - read my post again. Then read the documentation for HttpServletResponse - SC_METHOD_NOT_ALLOWED = 405 response code.
You may think that you are correctly addressing the servlet with the doPost method, but that response code indicates that you are not getting through to it.
As Vijay suggests, look carefully at the form that is supposed to be sending a request to the servlet and the URL it is addressing.
Also, you might look at the Tomcat logs to see what Tomcat is seeing - you should be able to see every single request.
Bill
 
bacon. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic