How to invoke a Servlet?

Answer Posted / chandra kunchala

you can invoke the servlet by two ways
one is dierctly u can invoke from address bar
like the following
http://<servername>:<port-Number>/<web-application-name>/<url-pattern
of perticular servlet>

eg:- http://localhost:8080/app1/test

second one is u can invoke by using form..
<form action="/app1/test">
.....
.....
</form>

web.xml:-

<servlet>
<servlet-name>FirstServlet</servlet-name>
<servlet-class>pack1.pack2.ClassName</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FirstServlet</servlet-name>
<url-pattern>/test</url-pattern>(test should be equal
to what u typed in the address bar after the web-application
name or should be equal to what u mention in the form action
after the web-application name)
</servlet-mappin>

Is This Answer Correct ?    16 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How would you create deadlock on your servlet?

622


What is the effective way to make sure all the servlets are accessible only when user has a valid session?

571


Explain their methods? Tell me their parameter names also have you used threads in servlet?

584


How to get the IP address of client in servlet?

630


What is servlet initializer?

505






What are the life cycle methods of a servlet?

594


What is http servlet? Explain with the help of an example.

581


Describe the phases of servlet lifecycle?

633


What is the difference in between the httpservlet and generic servlet?

607


What is meant by Servlet? What are the parameters of service method?

599


What is called servlet container?

665


Why do we use sendredirect() method?

550


What is the element?

590


Can we fetch the attributes related to a servlet on a different servlet?

636


What is the use of servlet context?

535