If you want to create a web site with dynamic pages, you should be creating a web application using servlets and JSP. Assuming you want to stick with Java. There are other alternatives such as PHP.
You can't just write a standalone Java app and integrate into an HTML page.