Alright well im trying to code a multiplication table for a webpage im making. This needs to be in a separate java Servlet as opposed to an inline javascript.
Basically the code should output embedded html code something like
<table>
<tr><td>4*0=0</td><td>4*1=4</td><td>4*2=8</td></tr>
<tr><td>5*0=0</td><td>5*1=5</td><td>5*2=10</td></tr>
<tr><td>6*0=0</td><td>6*1=6</td><td>6*2=12</td></tr>
</table>
There is an HTML Form with a beginning number prompt and ending number prompt and a limit denoting the number of multiplications per row.
i think i have arrived at the logical code for the parameter obtaining, but am having some trouble with the actual implementation of how to carry out the input and result in javascript.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
Public class Table extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
public class Counter extends HttpServlet {
private int v;
private List<String> starts;
private List<String> ends;
private List<String> mults;
public void init() {
v = 0;
starts = new ArrayList<String>();
ends = new ArrayList<String>();
mults = new ArrayList<String>();
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String start = req.getParameter("start");
String end = req.getParameter("end");
String mult = req.getParameter("mult");
if (!start.isEmpty()) {
v += Integer.parseInt(start);
starts.start(start);
}
if (!end.isEmpty()) {
v += Integer.parseInt(end);
ends.end(end);
}
if (!mult.isEmpty()) {
v += Integer.parseInt(mult);
mults.mult(mults);
}
PrintWriter o = res.getWriter();
String r =
NOTE: i dont know if that logically sound...thats why im looking for help. Thanks in advance to anyone who takes the time.