You can use most programming languages (perl, c/C++, etc.) to make CGI. However, if you use perl for CGI, a process will be generated for each query and will
be destroyed after a query is finished. This working
mechanism ( create and destroy )can make a server very busy when many sessions of queries come in and is not efficient. Java creates a thread for each session. Only after the session is finished, the thread is destroyed. Therefore, Java is much more efficient. The disadvantage of Java is that you need to know OO. Perl is simple to learn. Even high school students can use perl, probably not Java.
Wish it helps.