File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes HTTP status 405 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP status 405" Watch "HTTP status 405" New topic

HTTP status 405

upanshu vaid
Ranch Hand

Joined: Sep 07, 2012
Posts: 82

Hi, i am getting the following message "The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL)."The above message is coming when i am doing the following steps
1)I have entered the following url http://localhost:8080/Beer-v1/form.html in IE

2)when i select the color and hit the submit button getting the meesage that is colored in red.
i am posting the HTML, web.xml and servlet file

HTML file

<h1 align="center">Beer Selection Page</h1>
<form method="POST"
action ="">
Select beer characteristics

<select name="color" size="1">
<option value="light">light</option>
<option value="amber">amber</option>
<option value="brown">brown</option>
<option value="dark">dark</option>

<input type="SUBMIT">


<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app xmlns=""
xmlns:xsi="" xsi:schemaLocation="" version="2.5">
<servlet-name>Ch3 Beer</servlet-name>
<servlet-name>Ch3 Beer</servlet-name>


package com.example.web;
import javax.servlet.*;
import javax.servlet.http.*;
public class BeerSelect extends HttpServlet{
public void dopost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
PrintWriter out=response.getWriter();
out.println("Beer Selection Advice
String c=request.getParameter("color");
Got beer color"+c);

i have checked the directory structure and it looks fine,kindly revert me asap.

[Thumbnail for Untitled.jpeg]

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63547

dopost != doPost

This is Java. Case counts!

[Asking smart questions] [About Bear] [Books by Bear]
Vineet P Rao

Joined: Sep 17, 2012
Posts: 3
You are trying to POST the HTML page but there is no method in your servlet to handle this request.

As correctly pointed out in the previous post, here is the signature of the doPost method you should be using to handle POST requests:

Make sure you have the correct method in place and you should be fine.

My blog:
I agree. Here's the link:
subject: HTTP status 405
It's not a secret anymore!