This discussion is archived
1 2 Previous Next 19 Replies Latest reply: Oct 18, 2012 11:10 PM by Hjava RSS

run servlet on localhost

Hjava Newbie
Currently Being Moderated
I have tomcat 7.027 on local
I am able to see
1)http://localhost/
2)http://localhost/MyProject/index.jsp
3)http://localhost/MyProject/Hello ( servlet)
4)My other servlet did not have either doGet or doPost but it can run on other servers, I would like to let them run on localhost, but I get 405 error, what do I miss?
type Status report

message HTTP method GET is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).
  • 1. Re: run servlet on localhost
    gimbal2 Guru
    Currently Being Moderated
    implement doGet() because no matter what you think, you need at least that to be able to invoke a servlet through a GET request (which is what you do by navigating to it in a browser).
  • 2. Re: run servlet on localhost
    Hjava Newbie
    Currently Being Moderated
    *)My other servlet did not have either doGet or doPost but it can run on other servers, I would like to let them run on localhost, but I get 405 error, what do I miss?*
    type Status report
    It must have the other way to run it
  • 3. Re: run servlet on localhost
    Hjava Newbie
    Currently Being Moderated
    run now I get HTTP Status 404 -
  • 4. Re: run servlet on localhost
    jwenting Journeyer
    Currently Being Moderated
    gimbal2 wrote:
    implement doGet() because no matter what you think, you need at least that to be able to invoke a servlet through a GET request (which is what you do by navigating to it in a browser).
    There's no such requirement. If the servlet is never called from a client that sends it GET requests, it won't need a method to handle them. Of course if the servlet is called from a browser by typing in a URI or using a bookmark or link, the browser will send a GET request.
  • 5. Re: run servlet on localhost
    gimbal2 Guru
    Currently Being Moderated
    jwenting wrote:
    gimbal2 wrote:
    implement doGet() because no matter what you think, you need at least that to be able to invoke a servlet through a GET request (which is what you do by navigating to it in a browser).
    There's no such requirement. If the servlet is never called from a client that sends it GET requests, it won't need a method to handle them. Of course if the servlet is called from a browser by typing in a URI or using a bookmark or link, the browser will send a GET request.
    I would pretty much call the entire first post the requirement of which you claim is non-existent ;) Especially the error message generated by the server is a big hint.
  • 6. Re: run servlet on localhost
    aksarben Journeyer
    Currently Being Moderated
    This isn't exactly what you asked, but if you want to simplify your debugging, I'd ditch Tomcat & use Jetty when on the localhost. This would let you debug your server code in your IDE just as easily as you would debug a command line app. I used Tomcat & remote debugging for a many years before I discovered how much easier Jetty is.
  • 7. Re: run servlet on localhost
    Hjava Newbie
    Currently Being Moderated
    actually, the servlets work find on the services. since I can see the error messages, I try to reconfig the project let it can run on localhoost.
    1) at meantime, I can compile the servlet on my local NetBean that means I have all the relate libraris or classes.
    2) but the some URL
    http://theservers/Hello/CreateServlet/searchForm -> work fine
    http://localhost/Hello/CreateServlet/searchForm->get 404
    3) all the servlets extending a ConServlet , which is a jar file , it has both public void main and public void service
    what is the possible place that I miss?
  • 8. Re: run servlet on localhost
    818747 Newbie
    Currently Being Moderated
    what is the connector address in your server.xml
  • 9. Re: run servlet on localhost
    EJP Guru
    Currently Being Moderated
    I am wondering whether 'theservers' and 'localhost' are even the same sever, and whether he has really deployed his application to the localhost server at all.
  • 10. Re: run servlet on localhost
    jwenting Journeyer
    Currently Being Moderated
    gimbal2 wrote:
    jwenting wrote:
    gimbal2 wrote:
    implement doGet() because no matter what you think, you need at least that to be able to invoke a servlet through a GET request (which is what you do by navigating to it in a browser).
    There's no such requirement. If the servlet is never called from a client that sends it GET requests, it won't need a method to handle them. Of course if the servlet is called from a browser by typing in a URI or using a bookmark or link, the browser will send a GET request.
    I would pretty much call the entire first post the requirement of which you claim is non-existent ;) Especially the error message generated by the server is a big hint.
    nowhere does he state he's calling it from a browser (or otherwise using a GET request) :)
    It's highly likely, but with all the webservices kids are now trying to make as their very first forays into Java ever, hardly guaranteed.
  • 11. Re: run servlet on localhost
    EJP Guru
    Currently Being Moderated
    The error message states that he's calling it with a GET request somehow or other, which is the only point at issue.
  • 12. Re: run servlet on localhost
    Hjava Newbie
    Currently Being Moderated
    I am wondering whether 'theservers' and 'loc>alhost' are even the same sever, and whether he has really deployed his application to the localhost server at all.
    ofcourse, no! I rey to reconfig in order to let the code , which is can run on theserves also can run on the localhost
  • 13. Re: run servlet on localhost
    EJP Guru
    Currently Being Moderated
    I can't make much sense of that, but if you haven't deployed the Servlet to a Servlet container running in localhost, it will not execute on localhost.
  • 14. Re: run servlet on localhost
    Hjava Newbie
    Currently Being Moderated
    I using Tomcat, I did deploy the project on localhost
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points