Demo entry 6777212

Homework.java

   

Submitted by anonymous on Dec 09, 2018 at 00:49
Language: Java. Code size: 1.0 kB.

package com;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/Homework")
public class Homework extends HttpServlet {

	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String color = request.getParameter("color");
		int num1 = Integer.parseInt(request.getParameter("num1"));
		int num2 = Integer.parseInt(request.getParameter("num2"));
		PrintWriter out = response.getWriter();
		
		out.print("<html><body><table border='1px solid black' bgcolor='"+color+"'>");
		for (int i = num1; i <= num2; i++) {
			out.print("<tr>");
			for (int j = 1; j <= 9; j++) {
				out.print("<td>"+i+" x "+j+" = "+(i*j)+"</td>");
			}
			out.print("</tr>");
		}
		out.print("</table></body></html>");
	}
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).