Hi,
You are right. DON'T call res.getWriter().
You see the res.sendRedirect() works by sending a header field
to the browser.
So if you call res.getWriter() the header fields are set allready.
Hope it solves your problem.
Best wishes,
Andras.
----- Original Message -----
From: Jose Miguel Rodriguez <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 16, 2000 6:20 PM
Subject: sendRedirect on Linux. Please help!!
> Hello all,
>
> I'm having a big trouble and I'm sure it must be something stupid.
>
> The following code runs OK on Solaris 5.7, JDK_1.2.1_03 and Win/NT 4.0,
> JDK-1.2-V, but it doesn't on Linux RedHat 6.1, JDK 1.2.2 (build
Linux_JDK_RC3)
> .. As usual, the final deploy plataform will be Linux :-(
>
> The problem ocurrs when trying to redirect to a new page. The servlet
doesn't
> break, but I get and error on client (all cases, a Netscape 4.7 on WNT 4)
about
> 'the server has closed the connection.. tcp error.. '. All other
functionalities
> seems to run quite right, and fast.
>
> I have the following code:
>
> // --------------------------------------------------
>
> public class myServlet extends HttpServlet{
> ..
> ..
>
> protected void doPost(HttpServletRequest .....) throws ServletException{
>
> Class myClass = Class.forName(vsPage);
> module = (VSModuloLwas)myClass.newInstance() ;
> ...
> ... (setParameters.. etc)
> ...
> module.go() ;
> // --------------------------------------------------
>
> And on class VSModuloLwas (in fact this class it's an interface... doesn't
> matter)
>
> // --------------------------------------------------
> public int onInit() {
> [...]
>
> HttpServletResponse res = getHttpOutput().getHttpServletResponse() ;
> sUrl = "/lwas/frames.htm" ;
>
> // res.setStatus(HttpServletResponse.SC_RESET_CONTENT);
> try {
> res.sendRedirect(sUrl);
> lRet = true ;
> } catch (Exception e) {
> getLog().write("Error redirecting to URL: "+sUrl) ;
> }
> }
>
> file://---------------------------------------------------------
> In the meantime, while creating this structure of classes I've got the
> getWriter() from given HttpServletResponse (if this could affect in some
way.
>
> I've tried to go thru encodeRedirectURL(), encodeURL(), non relative
URLs.. and
> I cannot get it run. It ever works well on Windows or Solaris, and never
under
> Linux.
>
> Thank you everyone.
>
> --
>
> saludos,
> jmiguel
>
> Virtual Software,
> http://www.virtualsw.es/
> ICQ 13550064
>
>
___________________________________________________________________________
> 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
___________________________________________________________________________
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