Java Server Pages and Common Gateway Interface (CGI) usually provide the same program functionality. But there are few advantages or features only offered by the Java Server Pages.
• JSP provided support to use and embed expressions and dynamic elements in HTML page. Where as in CGI, a separate CGI file is used for the same purpose. Thus Java Server Pages provides better performance as compared to CGI.
• A JSP page is compiled by the web server before it is processed or invoked.