Error 403--Forbidden when trying to access the servlet

Discussions

Web tier: servlets, JSP, Web frameworks: Error 403--Forbidden when trying to access the servlet

  1. I have a servlet in test.war (examples.servlet.testServlet) and defined it in the web.xml and mapped to testServlet in the servlet mapping.
    When I access this servlet http:/localhost:7001/testServlet, I get the following error:
    Error 403--Forbidden
    From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
    10.4.4 403 Forbidden
    The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.

    Using Weblogic 6.1 apps server.
     
    Not sure what I'm doing wrong. Your help is greatly appreciated.

    Srikumar
  2. Code to be executed when a user enters the URL directly or redirects to a servlet URL should be put in the doGet method. Code to be executed on <form> submissions should (but not necessarily) be in the doPost method (depending on if the user should see it in the URL or not).

    You probably have a doHead method and that access restrictions on how it's accessed.

    Try using doGet and doPost unless you have a specific requirement for doHead...

  3. My understanding is that you need to include the web app context while invoking the servlet, irrespective of the mapping you may have defined.
    So the correct url would be: http://hostname/appcontext/servletalias

  4. Thanks for your help.
    Adding the context root helped.

    On a different note:
    Is there a way to call the servlet without mentioning the context root.
    Could the URL be this way :
    http://hostname/servletalias

    which in turn refers to
    http://hostname/appcontext/servletalias

    I'm using bea weblogic 6.1 and iPlanet w/s 4.1

    Thanks
    Srikumar