0

Tomcat 7 by Dissection: Passing HTTP POST Parameters to CGI Scripts

NOTE: “Tomcat 7 by Dissection” is a collection of blogs pinpointing, and detailing some Tomcat 7  functionalities on code level . The blogs are meant as code “footprints” for the author.

In my previous post, “Tomcat 7 by Dissection: How request parameters are set”, I mentioned an issue with one of the functionalities in a web application I maintain.

I have realized something after hours of code tracing and testing. There is pretty good explanation to why BufferedReader.read() or BufferedReader.readLine() hangs on HTTP POST transactions from CGI scripts.

Here is a way to put it:

perl_http_post_no_args

PERL is waiting for some inputs

The rationalization has stopped.

The fix was essentially a code to pass parameters to PERL (and CGI script) from within Java. In technical terms, converting the query string into bytes, and writing them to the output stream. This was missing in that web application CGI functionality. POST or GET, everything was GET.

In Tomcat, the passing of parameters to PERL (and CGI script) happens in org.apache.catalina.servlets.CGIServlet class.

TC 7.0.12

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert