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 7754225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:15:15+00:00 2026-06-01T12:15:15+00:00

I have a servlet named HelloServlet.. import java.io.*; import javax.servlet.*; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest;

  • 0

I have a servlet named HelloServlet..

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class HelloServlet extends HttpServlet
    {
public void doGet(ServletRequest request, ServletResponse response)
throws ServletException, IOException
{


        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        pw.println("<html>");
        pw.println("<head>");
        pw.println("<title> Hello World </title>");
        pw.println("</head>");
        pw.println("<body>");
        pw.println("<h1> Hello, World!</h1>");
        pw.println("</body>");
        pw.println("</html>");
        pw.close();




}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
    doGet(request, response);
}
    }

I compile it to a .class file and i place it in my tomcat directory under C:/tomcat/webapps/ALTest1/WEB-INF/classes/ – I made the servlet mapping (I put the url-pattern as /hi) and servlet entry for it in C:/tomcat/webapps/ALTest1/WEB-INF/web.xml

Everything works fine but when I go to my browser to access it at http://localhost:8080/ALTest1/hi I get an error message saying:

HTTP STATUS 405 - HTTP METHOD GET is not supported by this URL

…which is strange, because I have BOTH doPost and doGet methods in my HelloServlet.class file. So, even if doGet isn’t supported, I have the doPost method to take care of POST yet it still isn’t working.

  • 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-06-01T12:15:16+00:00Added an answer on June 1, 2026 at 12:15 pm
     public void doGet(ServletRequest request, ServletResponse response)
    

    That should have been HttpServletRequest and HttpServletResponse, just like in doPost.

    Always use @Override, that would have told you about this error.

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

Sidebar

Related Questions

I have the following servlet: public class MyServlet extends HttpServlet { private static final
In my web.xml of my simple app i have <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>HelloServlet</servlet-class> </servlet> <servlet-mapping>
I have the following servlet coded in /src/main/java/examples/web/SimpleServlet.java : package examples.web; import java.io.IOException; import
I have the servlet name ExampleServlet.java which have only init method with HttpServletRequest and
I have this managed bean based on this tutorial . import java.io.Serializable; import javax.enterprise.context.SessionScoped;
In my spring-servlet.xml I have <bean id=messageSource class=org.springframework.context.support.ReloadableResourceBundleMessageSource> <property name=basename value=/WEB-INF/messages /> </bean> My
I have this managed bean which takes two values from database's table import java.io.Serializable;
I have specified my JAX-RS Application in the web.xml as follows: <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class>
I have a simple servlet say com.test.HelloWorld.class then I create these folders tree: WEB-INF
In web.xml I have the following: <servlet> <description>JAX-WS endpoint - EARM</description> <display-name>jaxws-servlet</display-name> <servlet-name>jaxws-servlet</servlet-name> <servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>

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.