I have the following servlet and the sendRedirect works under IE 4.0 but not
under Netscape 4.61. For netscape when the "Test redirect" button is pressed
it displays:


"Document moved

This document has moved here."

I am using the servlet runner and JDSK2.0. Am I using sendRedirect
correctly?

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class TestServlet extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
  resp.setContentType("text/html");
  PrintWriter out = resp.getWriter();

  out.println("<HTML><HEAD><META HTTP-EQUIV=\"Cache-Control\" CONTENT=\"no
cache\">");
  out.println("<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no cache\"><TITLE>HTML
directory");
  out.println("</TITLE></HEAD><BODY TEXT=\"#800000\"
BGCOLOR=\"#FEFBEB\"><FORM METHOD=\"POST\"
ACTION=\"/servlet/TestServlet\">");
  out.println("<BR><INPUT TYPE=\"SUBMIT\" VALUE=\"Test redirect\"
NAME=\"Test redirect\">");
  out.println("</FORM></BODY></HTML>");

  out.close();
}

public void doPost(final HttpServletRequest req,
       HttpServletResponse resp)
  throws ServletException, IOException
{
  int port = req.getServerPort();
  String abs =  req.getScheme() + "://" + req.getServerName() +
      (port == 80 ? "" : ":"+port) + req.getServletPath();
  System.out.println( "Redirecting to: " + abs );
  resp.sendRedirect( abs );
}

}

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to