0

When I post xml data in header it is saying Request header is too large. I tried all the solutions posted on Stackoverflow.

Request header is too large

JAVA -tomcat- Request header is too large

I am using Spring-MVC-Ajax.

Below is the Ajax Call

$("#btnSubmitEdit").click(
                        function(event) {
                            $(document.body).css({"pointer-events": "none", "cursor": "wait"});
                            var reqMsgId = $("#msgID").val();
                            var reqMsg = $("#xmlMessage").val();
                            $.ajax({
                                        url : "update/" + reqMsgId,
                                        data:{reqMsg: encodeURIComponent(reqMsg)},
                                        type : "POST",
                                        success : function(data) {
                                            $(document.body).css({"pointer-events": "", "cursor": "default"});
                                        },
                                        error : function(e) {
                                            $(document.body).css({"pointer-events": "", "cursor": "default"});
                                            alert("Error" + e.responseText);
                                        }
                                    });
                        });

Here is spring controller

@RequestMapping(value = "/update/{reqMsgId}", method = RequestMethod.POST)
public @ResponseBody String updatePage(@PathVariable("reqMsgId") String reqMsgId, @RequestParam("reqMsg") String reqMsg) {
    System.out.println(reqMsg);
    esbresubmitmessageservice.updateMessage(reqMsg, Integer.parseInt(reqMsgId));
    return "success";
}

Getting following Error :

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.InternalInputBuffer.fill(InternalInputBuffer.java:512)
    at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:501)
    at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:171)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:996)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Community
  • 1
  • 1
Raju
  • 1
  • 1
  • 3
  • Don't use this: `url : "update/" + reqMsgId + "?reqMsg=" + encodeURIComponent(reqMsg),`...use `url : "update/" + reqMsgId, data:{reqMsg: encodeURIComponent(reqMsg)}` – Hackerman Nov 15 '16 at 14:35
  • getting this error: WARNING: No mapping found for HTTP request with URI [/Appname/403] in DispatcherServlet with name 'mvc-dispatcher' – Raju Nov 15 '16 at 14:44
  • May be this is because of controller issue. Is that correct fiction to receive ajax post requests. – Raju Nov 15 '16 at 14:46
  • Yeah, it seems like a controller issue...you can check the Network tab(f12) on your browser to check the url you are pointing and to see if is rightly formed. – Hackerman Nov 15 '16 at 14:51
  • getting same issue. – Raju Nov 15 '16 at 15:04
  • I forgot to mansion that I am running this in eclipse – Raju Nov 15 '16 at 15:06
  • Well, for this kind of projects, and when your level of expertise is like, junior level, I would recommend you to write a simple method on your server code, and an ajax call on your client side...start adding parameters on both sides, looking at the request on the network tab...and once everything works fine and you have a major understanding, then move to something more complex.... – Hackerman Nov 15 '16 at 15:15
  • and why won't you use POST with xml body for your call? – Rahul Kumar Nov 15 '16 at 15:21
  • I have update above with POST but failed to receive in controller. – Raju Nov 15 '16 at 15:25

0 Answers0