Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sendRedirect() not working with POST request

Status
Not open for further replies.

Charlie100

Programmer
Nov 7, 2002
1
AU
When I redirect to same page with a post method, I get a error page in IE - "Page not available....Cannot find server or DNS error".
If I change the method to a GET , or change the page to any other page, it works fine.
Example code below. Note, I find this code works when I am developing in VisualAge for Java 3.5 under the Websphere Test Environment, but fails when I deploy on Websphere Server 3.5.3.

Thanks, in advance.

Code:
<%@ page session=&quot;true&quot; isThreadSafe=&quot;true&quot; 
    isErrorPage=&quot;false&quot; buffer=&quot;512kb&quot; autoFlush=&quot;true&quot; %>

 <HTML>
<HEAD>
<TITLE>Test redirecting</TITLE>
<% 
   response.setHeader(&quot;pragma&quot;, &quot;no-cache&quot;);
   response.setHeader(&quot;Cache-Control&quot;, &quot;no-cache&quot;);
   response.setHeader(&quot;Expires&quot;, &quot;0&quot;);
  if(request.getParameter(&quot;var&quot;)!=null){
    response.sendRedirect(&quot;[URL unfurl="true"]http://company:8080/Test.jsp&quot;);[/URL]
  }
%>

<SCRIPT>
 function doSubmit() {
  var f = document.mainForm;
  f.submit();
}
</SCRIPT>
</head>

<BODY>
<FORM name=&quot;mainForm&quot; method=&quot;post&quot; >
  <INPUT type=&quot;text&quot; name=&quot;var&quot;>
  <INPUT type=&quot;button&quot; value=&quot;Search&quot; onclick=&quot;doSubmit()&quot;>
</FORM>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top