coder0007 coder0007 - 4 months ago 40
HTTP Question

Submitted form data visible in url despite using method=post

I have used POST as the method when submitting form data (namely textarea), but it is still visible in the URL. This is causing the following error in my web application (running on NetBeans):

Aug 30, 2016 11:25:02 AM org.apache.coyote.http11.AbstractHttp11Processor process
INFO: Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Request header is too large
at org.apache.coyote.http11.InternalAprInputBuffer.fill(
at org.apache.coyote.http11.InternalAprInputBuffer.parseRequestLine(
at org.apache.coyote.http11.AbstractHttp11Processor.process(
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
at org.apache.tomcat.util.threads.TaskThread$

This is caused due to the limit exceeded in the URL (from what I have gathered).

index.jsp (code fragment):

form id="maryWebClient" action="preprocess" method="POST">

I have also later tried to explicitly set the method as POST by using the following code in, to which data is being sent by using urlPatterns from index.jsp (code fragment):

URL obj=new URL("http://..../process?INPUT_TEXT="+"\""+ URLEncoder.encode(sent)+"\""+ "&INPUT_TYPE=TEXT&OUTPUT_TYPE=REALISED_DURATIONS&LOCALE=hi_IN&OUTPUT_TYPE_PARAMS=phone+stressed+accented");
BufferedReader bfr=new BufferedReader(new InputStreamReader(obj.openStream(),"utf8"));
HttpURLConnection con = (HttpURLConnection) obj.openConnection();


The following approach solved my problem. I have used ajax call to send a post request.

var postData=$("#maryWebClient").serializeArray();

     url: "preprocess",

     success: function(response){
             error: function(errorData){alert(errorData);}