When using sendRedirect, I always get a page returned stating: "Document moved." Is it possible to go directly to the redirected page?

Nicola Ken Barozzi

There are two possibilities.

Personally I am using the Jigsaw Web Server from the World Wide Web Consortium and I do not encouter the problem: if I send a redirect the new page automatically loads.

CODE: PageName is a String containing the redirect URL


Another possibility is to send a META refresh as a response page, so that the browser calls the page you want to redirect to after your response loads. To be sure, put the redirect link on the page, just in case.

CODE: PageName is a String containing the redirect URL

    PrintWriter TempWriter = response.getWriter();

    "&lt;META HTTP-EQUIV="Refresh" CONTENT="5";URL=""+PageName+""&gt;"+
    "&lt;/HEAD&gt;<BODY>Redirecting to: &lt;A href="+PageName+" "&gt;"+PageName+"&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;");

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.