jspinternet-explorergetparameter

JSP page in IE not receiving POST parameters. Works in Chrome


A pretty simple setup. HTML form

<form id="ChromeEmailForm" method="POST" action="ChromeEmail.jsp" target="ChromeEmailWindow" >
    <input type="hidden" name="emailSubject" value="something" />
    <input type="hidden" name="htmlBody" value="something" />
</form>

Submitted by JS:

document.getElementById('ChromeEmailForm').submit();

and retrieved in the JSP using:

<%=request.getParameter("emailSubject")%>

Works fine in Chrome, but returns "null" in IE (11) in the ChromeEmail.jsp page. Page is returned in both browsers.

Tried adding JSP to force encoding but didn't make a difference:

<%@ page contentType="text/html; charset=utf-8"%>
<%request.setCharacterEncoding("UTF-8");%>

Is this an known IE feature?


Solution

  • Turns out that this IS an IE feature, as documented here: Challenge-Response Authentication and Zero-Length Posts

    From the article:

    For performance reasons, Internet Explorer does not immediately transmit a POST body if it expects to immediately receive a HTTP/401 response with a challenge for credentials. Without this optimization, IE would be forced to reupload the (potentially large) POST body multiple times, wasting bandwidth.

    Which explains why POST data goes missing in an authentication site.