Estou estudando Servlets e JSP pelo livro Use a Cabeça
e quando eu executo , ele abre o html, quando eu seleciono o tamanhoe clico no botão, ele não me retorna nada, porque???
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Testando Array</title>
</head>
<body>
<h1 align="center">Seleciona a quantidade</h1>
<form method="POST" action="SelectTamanho.do">
Selecione o Tamanho
<input type=checkbox name=sizes value="12oz">12 oz.<br>
<input type=checkbox name=sizes value="16oz">16 oz.<br>
<center><input type="SUBMIT"></center>
</form>
</body>
</html>
package com.example.web;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class TamanhoSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
//String one = request.getParameterValues("sizes")[0];
String [] sizes = request.getParameterValues("sizes");
PrintWriter out = response.getWriter();
for (int x=0; x < sizes.length; x++)
{
out.println("<br>sizes: " + sizes[x]);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<servlet>
<servlet-name>Ch4 Beer</servlet-name>
<servlet-class>com.example.web.TamanhoSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ch4 Beer</servlet-name>
<url-pattern>/SelectTamanho.do</url-pattern>
</servlet-mapping>
</web-app>