hi i'm learning html and sevlets,i wrote small aplication but i'm not getting any output when i click submit button from from.html page: below is my code
<html>
<body>
<h1 align="center>Color Selection Page</h1>
<form method="POST" action="/SelectColor.do" >
Select Color Charecterstics<p>
Color:
<select name="color" size="1">
<option>light
<option>amber
<option>brown
<option>dark
</select>
<br><br>
<center>
<input type="submit" value="Submit">
</center>
</form>
</body>
</html>
web.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>ColorServlet</servlet-name>
<servlet-class>com.example.web.ColorServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ColorServlet</servlet-name>
<url-pattern>/SelectColor.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>form.html</welcome-file>
</welcome-file-list>
</web-app>
servlet
package com.example.web;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ColorServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException{
res.setContentType("text/html");
try {
PrintWriter out = res.getWriter();
out.println("Beer Selection ADvice<br>");
String c=req.getParameter("color");
out.println("<br>Got beer color "+c);
} catch (IOException e) {
e.printStackTrace();
}
}
}