Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 714669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:06:04+00:00 2026-05-14T05:06:04+00:00

My web.xml is like <web-app version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd> <display-name>sample</display-name> <servlet> <servlet-name>Sampleclass</servlet-name> <servlet-class>sample.SampleClass</servlet-class>

  • 0

My web.xml is like

    <web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>sample</display-name>
    <servlet>
        <servlet-name>Sampleclass</servlet-name>
        <servlet-class>sample.SampleClass</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Sampleclass</servlet-name>
        <url-pattern>/SampleClass</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>/page/form.jsp</welcome-file>
    </welcome-file-list>
</web-app>

and form.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <h1>A simple web application</h1>
        <form method="POST" name="Sampleclass" action="SampleClass">
            <label for="name">Enter your name </label>
            <input type="text" id="name" name="name"/><br><br>
            <input type="submit" value="Submit Form"/>
            <input type="reset" value="Reset Form"/>
        </form>
</body>
</html>

and SampleClass.java is

public class SampleClass extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) 
                throws ServletException, IOException {
        String name = request.getParameter("name");
        String age = request.getParameter("age");
        PrintWriter out = response.getWriter();
        out.write("<html>Hello Your name is "+name +", and your age is "+age+"</html>");
    }
    public void destroy() {

    }


}

but I am getting error when I entered to submit button of form.jsp
and error is

type Status report

message HTTP method POST is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL).

I am not understanding that what is the problem exactly ? Please help..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:06:04+00:00Added an answer on May 14, 2026 at 5:06 am

    Your web.xml and <form> are all perfectly fine. The servlet must be mapped on /servleturl and the form action must point to servleturl.

    The error message also proves that the servlet is perfectly found:

    message HTTP method POST is not supported by this URL

    You would otherwise have gotten a 404 Page Not Found (servlet not found) or maybe worse a 500 Internal Server Error (servlet failed to execute).

    The error you got basically means that there’s no doPost() method. However, your code example do contain it. This can have only one cause: you are not running the servlet class version you think you are running. The one currently deployed does not have the doPost() method. Clean up everything, recompile/rebuild everything, redeploy the webapp, restart the server and try again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 351k
  • Answers 351k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could do a server install which doesn't require Visual… May 14, 2026 at 7:15 am
  • Editorial Team
    Editorial Team added an answer Hate to state the obvious first, but did you add… May 14, 2026 at 7:15 am
  • Editorial Team
    Editorial Team added an answer You mean something like so?: Insert EffectiveDatedAttributes ( Id, Col1,… May 14, 2026 at 7:15 am

Related Questions

I'm trying to get into Java web development but seem to be running into
I have an application that is running Jaxb 2.1.12. I am running JDK 1.5
Eclipse is showing the following errors in my Spring's applicationContext.xml : cvc-complex-type.2.4.c: The matching
The top of my web.xml file looks like this: <?xml version=1.0 encoding=UTF-8?> <web-app xmlns=http://java.sun.com/xml/ns/j2ee
probably this is a lack of attention issue, if so, forgive me, but I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.