How to invoke a Servlet?

Answer Posted / dara

<form action="/servlet/full.class.name">
</form>


This method uses the invoker servlet, provided by many
servlet containers. The much better way of invoking a
servlet is by providing an explicit mapping for it. This is
accomplished by using a pair of tags in your web
application's web.xml file. This is not the same file as
mentioned above. That file was located in Tomcat's conf/
directory. This web.xml file (which you will probably need
to create) will reside in your web-application's WEB-INF/
directory. For each servlet you want to call, provide a
pair of tags like the following:


...
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>your.package.name.HelloWorld</servlet-
class>
</servlet>
...
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
...

Is This Answer Correct ?    8 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How a servlet is unloaded?

800


Whether we can get deadlock situation in servlets?

805


What do you mean by request dispatcher in servlet? Also explain its methods.

845


Tell us something about servletcontext interface.

826


Explain how to improve Servlet Performance?

826


What is the difference between the http servlet and generic servlet?

872


Why is servlet used?

896


Which are the different ways you can communicate between servlets?

736


What is the main purpose of java servlets?

789


How can you run a servlet program?

793


What is difference between PrintWriter and ServletOutputStream?

994


Which interface must be implemented by all servlets?

1027


What is the difference between context parameter and context attribute?

729


What is a deployment descriptor?

841


how to link html file to sevlet file.one name is textbox,c&c++ is cheakbox,bc&mca is radio button and one submit buttonis ok why in this programme use in servelt file

2340