I have a homework to get the average of x number...I was thinking that in order to get this I should just ask the user to input all the numbers that that want to get and using comma as separator...unfortunately, I don't know how to do this...below I have my HTML and my servlet which I don't know how to continue...please help...
This is my HTML
<!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>Insert title here</title>
</head>
<body>
<p>Average</p>
<form action="AverageNumber" method=get>
<p><input type=text name=number></p>
<input type=submit name=submit value=Submit>
</form>
</body>
</html>
This is my servlet:
import java.io.*;
import java.util.Arrays;
import javax.servlet.*;
import javax.servlet.http.*;
public class AverageNumber extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
int number = Integer.parseInt(request.getParameter("number"));
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Sorting Servlet</title>");
out.println("</head>");
out.println("<body>");
out.println(answer);
out.println("</body>");
out.println("</html>");
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request, response);
}
}