4

I just started playing with Google App Engine and Java. I've used Servlets in the past and I understand how they work. I'm trying to make a servlet to POST to, but it's not going over very well.

Here's my Servlet:

public class CreateUser extends HttpServlet
{
    private static final long serialVersionUID = 1L;

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        ...
    }
}

Here's what I get when I post to this from a form:

HTTP ERROR 405
Problem accessing /user/create. Reason:
HTTP method POST is not supported by this URL

I don't understand why I'm getting this when I clearly have implemented doPost. I've double and triple checked the DD (web.xml) file to make sure I have the url mappings correct. I can't find anything online specifically about this. I figure I am over looking something quite simple.

Here's my web.xml:

<web-app...>
    ...
    <servlet>
        <servlet-name>CreateUser</servlet-name>
        <servlet-class>com.joelj.music.api.CreateUser</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Index</servlet-name>
        <url-pattern>/user/create</url-pattern>
    </servlet-mapping>
</web-app>

Thanks.

3
  • 2
    I don't see the annotation for servlet registration, so I assume it's in web.xml. Could you post web.xml for us? Commented Aug 5, 2010 at 6:36
  • Yeah, I'll get that up as soon as I can. I don't have access to the code right at the moment though. I'll get it up in a couple hours. Thanks. Commented Aug 5, 2010 at 14:43
  • Ok, I updated the code. I have removed that entry in web.xml just to see if the error changes and it changes to 404 File Not Found. So it's going to that servlet, it just doesn't see my doPost Commented Aug 5, 2010 at 19:10

1 Answer 1

5

I feel really stupid. After looking at the code I just posted I realized that the entry was pointed to Index. I can't believe I over looked it so many times.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.