In particular, in the problem I've attached (which works OK), a big problem is that the canvas is cleared upon submission, because I don't know how to save all the points of the graph persistently. I think this could be handled (among other things) if I was using an applet and not just a canvas element directly in the problem.
Any help would be most appreciated.