calling a servlet in tomcat

R

royG

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
 
J

Jan Thomä

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
 
O

Owen Jacobson

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
 
R

royG

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top