If you are doing on web pages with Java, I think you are using JSP/Servlets. If so,
1. The JSP/Servlets must run in an J2EE web container, such as Tomcat,... But CGI just run in a http web server, such as an Apache Server.
2. JSP/Servlets and CGI, they are competitors each other. JSP/Servlets can do multi-thread in Web Server, but CGI can not. It means, an instance of JSP/Servlets can provide service to multi-user at the same time, but one loaded CGI just can only provide service to one user,.... big different performance on web server, ..... That's why Java is a winner right now.