Contact:   Tel: 2726  -  New Media Systems, 1st Floor South, Queens Walk



I have a feeling (but I might be wrong) that the sendRedirect only works for
POST method. For GET method, try to use RequestDispatcher instead.


Charles






Geeta Ramani <[EMAIL PROTECTED]> on 09/28/2000 02:06:41 PM

To:        [EMAIL PROTECTED]
cc:         (bcc: Charles Chen/YellowPages)
From:      Geeta Ramani <[EMAIL PROTECTED]>, 28 September 2000, 2:06 p.m.

Re: Redirection Trouble  [Scanned by Yellow Pages PostMaster]


Hi Roy: I think it's because you cannot commit response to your browser before
you try to redirect. Here's what the docs say:

    If the response has already been committed, this method throws an
IllegalStateException. After using this
    method, the response should be considered to be committed and should not be
written to.

Geeta

"Roy Silva (Java)" wrote:

> hi,
>
> I have a servlet which redirects the page. when i call it from .shtml using
> <servlet code=/...>
> </servlet>
>
> it does not redirect the page. however, if i call the servlet directly, say
> (just for testing!) server/servlet/test
> then it redirects the page!.
>
> where am i going wrong?
>
> public void doGet(HttpServletRequest request, HttpServletResponse response)
> throws ServletException, IOException {
>     response.setContentType("text/html");
>     PrintWriter out = new PrintWriter (response.getOutputStream());
>
>     HttpSession session = request.getSession(true);
>
>     // has the member logged in?
>     Object done = session.getValue("logon.isDone");
>
>     if (done == null) {
>
>       // save the target and redirect to login page
>       session.putValue("login.target",
> HttpUtils.getRequestURL(request).toString());
>
> //      response.sendRedirect(re);
>       response.sendRedirect("http://news.bbc.co.uk");
>       System.out.println("redirected");
>       return;
>     }
>     System.out.println("logged user");
>   }
>
> Many thanks for your time!
> roy
>
> ___________________________________________________________________________
> 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

___________________________________________________________________________
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