This seems like a pretty straightforward and easy thing to accomplish as a
Java web application -- is that what you're going for?
Sure, if you did this all as a blob in a PHP page, it'd be just as much as a mess as putting all the code into the equivalent
JSP page -- but that's not the right way to approach it. A multi-layered web app with appropriate structured layers to separate the concerns makes this kind of thing much easier to handle (and
test, and maintain, and extend, and so on...)
First, read
this article to make sure you understand what JSP is all about (shouldn't be much surprise here if you are familiar with PHP concepts), then read
this article to learn how to properly structure a Java web app.
That's all assuming you want to do this as a traditional Java web app.
In this scenario, you mentioned jQuery which could help out in a supporting role on the client side with event handling and the like.
But......... as you are the one who brought up JavaScript perhaps a traditional Java web app is not what you are after. In that case, read on to my next post...