This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Any question asked here at Ranch isnt a stupid question. We are all learners here and its always a pleasure helping.
now , to the main point ,
in web.xml file , you have an element called <servlet> which has child elements called <servlet-name> and <servlet-class> , You can give any name you want to the <servlet-name> , however you need to give fully qualified classname for the <servlet-class> element , If your servlet resides inside WEB-INF/classes folder , then simply the name of the java class would suffice and as Bear told , once this entry is done you need to map your java class to a URL Pattern which will be accessed from your HTML page.
For URL mapping also , there is a tag called <servlet-mapping> which further has to 2 child elements called <servlet-name> and <url-pattern>
So , If your servlet name is TestHelloWorld, then you need to have these entries in your web.xml
So now from your HTML page , if you have an form action like below then it would hit your Servlet and execute the logic written inside this.
<form action="/hello/abc" method="post"> <input type="Submit" value="Get Value from My First Servlet" /> </form>
Hope this helps. Yogendra Joshi.
Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....