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 do you define a servlet?

528


What is a servlet context?

603


Which application server is best for java?

560


Explain mvc pattern.

594


How is an application exception handling is done using a servlet?

541






What is webservlet?

539


What are the phases of servlet life cycle?

611


How to read request headers from servlets?

565


How can a servlet be used to generate plain text instead of html?

548


What are advantages of servlets over cgi?

632


What is the difference between the servlets and cgi programs?

551


What’s the difference between sendredirect and forward methods

568


What is servlet in web technology?

577


Which is better jsp or servlet?

560


Explain the different ways for servlet authentication?

534