aspose file tools*
The moose likes Servlets and the fly likes Crazy sendRedirect() problem -- Urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Crazy sendRedirect() problem -- Urgent" Watch "Crazy sendRedirect() problem -- Urgent" New topic
Author

Crazy sendRedirect() problem -- Urgent

jodi blair
Greenhorn

Joined: Apr 12, 2001
Posts: 14
I'm having this problem trying to redirect my servlet to another url. When I click an image on a form, it posts it, then saves info after which I call the response.sendRedirect method. It works up to the redirect then does nothing, no error or anything! When I look at the logs, it shows that the init() method never happened. I tried redirecting to another class, in case you couldn't redirect to the same class, but this gave the same results! What I was hoping you could help me with is just some suggestions as to what could be happening because I am honestly out of ideas! Thanks for any ideas! PS: the url works on its own
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
You will get a better response to this question in the Servelets and JSP's forum. I'm moving this thread there.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

i don't think response.redirect() will work if you've written data to the output stream.

Is this the case maybe? ps. If you servlet is compiled from a JSP, even a blank space in the JSP can result in the servlet opening and setting the response headers, which then means you can't redirect.
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Mike Curwen:
i don't think response.redirect() will work if you've written data to the output stream.

The Servlet spec says (v2.2: 6.3) that the redirect method should work as long as the response has not yet been committed. With the default JSP buffer size of 8kb, you should be able to successfully redirect if you generated less than 8kb worth of HTML. (The redirect will clear the buffer though, losing everything you've generated).
- Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Crazy sendRedirect() problem -- Urgent