calling a servlet in tomcat

Discussion in 'Java' started by royG, Nov 20, 2008.

  1. royG

    royG Guest

    forgive me if this is a silly doubt.But i am a newbie to tomcat

    I was trying out the examples in chapter2 of java servlet&JSP cookbook
    by Bruce W. Perry.The section of 'Deploying an Individual Servlet on
    Tomcat' tells to
    1.create a servlet (i made cookbook.SampleServlet.java that has doGet
    (..) method taking user input into some textfields and a doPost(..)
    that prints those input values) .
    2.copy the cookbook/SampleServlet.class into webapps/ROOT/WEB-INF/
    classes directory of tomcat
    3.start tomcat by running startup.bat

    but then the book says,the servlet can be invoked by
    http://localhost:8080/servlet/cookbook.SampleServlet

    I tried that,but am getting 404 error!
    How can i call the servlet ? I know how to do it thru web.xml using
    urlpattern .But i want to invoke this by calling the Servlet name
    directly.
    Pls help..
    thanks
    roy
     
    royG, Nov 20, 2008
    #1
    1. Advertising

  2. royG

    Jan Thomä Guest

    On 2008-11-20 17:45:49 +0100, royG <> said:

    > How can i call the servlet ? I know how to do it thru web.xml using
    > urlpattern .But i want to invoke this by calling the Servlet name
    > directly.



    I am not sure if what you ask is possible. Afaik you always need a
    web.xml to map your servlet to an URL...


    Jan
     
    Jan Thomä, Nov 20, 2008
    #2
    1. Advertising

  3. On Nov 20, 11:45 am, royG <> wrote:
    > forgive me if this is a silly doubt.But i am a newbie to tomcat
    >
    > I was trying out the examples in chapter2 of java servlet&JSP cookbook
    > by Bruce W. Perry.The section of 'Deploying an Individual Servlet on
    > Tomcat' tells to
    > 1.create a servlet (i made cookbook.SampleServlet.java that has doGet
    > (..) method taking user input into some textfields and a doPost(..)
    > that prints those input values) .
    > 2.copy the cookbook/SampleServlet.class into webapps/ROOT/WEB-INF/
    > classes directory of tomcat
    > 3.start tomcat by running startup.bat
    >
    > but then the book says,the servlet can be invoked byhttp://localhost:8080/servlet/cookbook.SampleServlet
    >
    > I tried that,but am getting 404 error!
    > How can i call the servlet ? I know how to do it thru web.xml using
    > urlpattern .But i want to invoke this by calling the Servlet name
    > directly.
    > Pls help..
    > thanks
    > roy


    Because it's a potential security risk, Tomcat no longer deploys the
    invoker servlet (which used to handle ROOT/servlet/*) by default. Set
    up a proper webapp with a web.xml file and deploy your servlet that
    way.

    -o
     
    Owen Jacobson, Nov 20, 2008
    #3
  4. royG

    royG Guest

    On Nov 20, 11:13 pm, Owen Jacobson <> wrote:
    > Because it's a potential security risk, Tomcat no longer deploys the
    > invoker servlet (which used to handle ROOT/servlet/*) by


    thanks guys for the replies
    Roy
     
    royG, Nov 20, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sean Clarke
    Replies:
    1
    Views:
    1,901
    Sudsy
    Jan 7, 2004
  2. Guest
    Replies:
    0
    Views:
    3,713
    Guest
    Jan 18, 2004
  3. circuit_breaker
    Replies:
    2
    Views:
    2,021
    Jack Jia
    Apr 4, 2004
  4. Doug McCann
    Replies:
    1
    Views:
    1,045
    William Brogden
    Aug 5, 2004
  5. Replies:
    0
    Views:
    849
Loading...

Share This Page