Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

HTTP status 405

 
Ranch Hand
Posts: 83
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

<html><body>
<h1 align="center">Beer Selection Page</h1>
<form method="POST"
action ="SelectBeer.do">
Select beer characteristics


Color:
<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>
</select>



<center>
<input type="SUBMIT">
</center>
</form></body></html>

web.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>

SERVLET

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

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

Untitled.jpeg
[Thumbnail for Untitled.jpeg]
Page
 
Sheriff
Posts: 67620
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dopost != doPost

This is Java. Case counts!
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic