• Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet not working

 
chan kgp
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have run a html file, as below

<html>
<body>
<h1 align="center"> Chicken selection</h1>
<form method="POST" action="SelectChicken.do">
Select chicken type


Type:
<select name="chicken" size="1">
<option>Tandoori
<option>Tikka
<option>Hyderabadi
<option>Butter Masala
<option>Chilly
</select><input type="SUBMIT">



<!--
<center>
<input type="SUBMIT">
</center>
-->
</form>
</body>
</html>


I also have compiled the ChickenSelect.java file, and placed it in webapps/WEB-INF/classes//com/example/web folder

without the web.xml file the form.html file is running. but as soon as I paste the web.xml file in the WEB-INF folder and run the html file it does not run anymore. Please help, have been stuck here for a long time. The following is the web.xml file

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">

<servlet>
<servlet-name>cc</servlet-name>
<servlet-class>com.example.web.ChickenSelect</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>cc</servlet-name>
<url-pattern>/SelectChicken.do</url-patter>
<servlet-mapping>

</web-app>

 
palanisamy subramani
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your web.xml is wrong.

You have not closed <servlet-mapping> properly and spell mistake in </url-pattern>

Below is the correctd one.

<servlet-mapping>
<servlet-name>cc</servlet-name>
<url-pattern>/SelectChicken.do</url-pattern>
</servlet-mapping>

Restart your server and check it out.
 
Virendrasinh Gohil
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chan,

It is always recommended to check logs for any issues while running web apps. You would have errors in log file for such issue.
 
chan kgp
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, it worked
Thank you very much, cant believe it was a typo
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!