Results 1 to 4 of 4
  1. #1
    mDennis10 is offline Member
    Join Date
    Jul 2011
    Posts
    76
    Rep Power
    0

    Default HTTP status 405 HTTP method GET is not supported by this URL

    Firstly, I am new to this thing. I am trying to create a RESTFul web service using the jersey framework the problem is that I don't know I am configure my project properly. My web service class is:
    Java Code:
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import javax.ws.rs.core.MediaType;
    
    @Path ("/test")
    public class Test {
    	private String name = "Worked";
    	
    	@GET
    	@Produces (MediaType.TEXT_PLAIN)
    	public String getTest ()
    	{
    		return name;
    	}
    }
    My web.xml configuration is:
    Java Code:
      <servlet>	
      	<display-name>Test</display-name>
      	<servlet-name>Test</servlet-name>
      	<servlet-class>org.LMS.Controller.Test</servlet-class>
      </servlet>
      <servlet-mapping>
      	<servlet-name>Test</servlet-name>
      	<url-pattern>/test</url-pattern>
      </servlet-mapping>
    And I invoke the webservice from a serlvet
    Java Code:
    @SuppressWarnings("serial")
    public class LoginAction extends HttpServlet{
    	
    	@Override
    	public void doPost (HttpServletRequest request, HttpServletResponse response)throws IOException,ServletException
    	{		
    		 ClientConfig config = new DefaultClientConfig();
    		 Client client = Client.create(config);
    		 WebResource service = client.resource(getBaseURI());
    		   
    		 System.out.println(service.path("test").accept(MediaType.TEXT_PLAIN).get(ClientResponse.class).toString());
    	
    	}//end doGet method
    	
    	private static URI getBaseURI() 
    	{
    	    return UriBuilder.fromUri("http://localhost:8080/Test").build();
    	}
    
    }//end LoginAction class
    Can someone tell me want I am doing wrong

  2. #2
    SpAm is offline Member
    Join Date
    Sep 2012
    Posts
    4
    Rep Power
    0

    Default Re: HTTP status 405 HTTP method GET is not supported by this URL

    Hi mDennis10

    The mtheod is calling via GET not POST.

    You have not overwritten the doGet() method, you need to.

  3. #3
    sbmk is offline Member
    Join Date
    Oct 2012
    Posts
    3
    Rep Power
    0

    Default Re: HTTP status 405 HTTP method GET is not supported by this URL

    Add this to your servlet file.

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

    You may also view this:-

    HTTP Status 405 - HTTP method GET is not supported by this URL

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,002
    Rep Power
    20

    Default Re: HTTP status 405 HTTP method GET is not supported by this URL

    You've got that backwards.
    They have a doPost, they don't have a doGet, so they would need to provide a doGet that would call doPost (as a minimum).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 1
    Last Post: 03-27-2012, 03:52 AM
  2. HTTP Status 500 -
    By gauravmanral in forum Java Servlet
    Replies: 2
    Last Post: 02-14-2012, 04:50 AM
  3. HTTP Status 500 -
    By aiesha in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-23-2011, 04:16 AM
  4. http://localhost:8080/helloservice/HelloService?Tester HTTP Status 404 -
    By vietnamusa in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 03-13-2011, 12:02 AM
  5. Replies: 7
    Last Post: 11-11-2009, 08:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •