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

Hi frnd can i any one kindly can post for me portlet,hibernate and spring example application and with flow explantion configuration using Jdeveloper.and related links ar tutorials kindly please send me .its urgent for me .thanks in advance...........else can any one send to kondaiah.goddeti@gmail.com

1738


How do you invoke a Servlet? What is the difference between doPost method and doGet method?

644


What is called Scriptlet?

561


What are the ways to handle multi-threading in servlets?

595


What do you mean by servlet context?

599






How to handle exceptions thrown by application with another servlet?

608


Elucidate servlet attributes and its scope?

567


List some life cycle methods of a servlet.

587


How many servlet objects are created?

561


When should you prefer to use doget() over dopost()?

661


What is servlet and list its types?

538


What do you mean by singlethreadmodel interface?

578


What is the procedure for initializing a servlet?

543


Explain the steps involved in placing a servlet within a package?

566


Difference between forward() method and sendredirect() method ?

582