Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Tomcat 3.2.4 problem after response.sendRedirect(...)

Reply
Thread Tools

Tomcat 3.2.4 problem after response.sendRedirect(...)

 
 
Andreas
Guest
Posts: n/a
 
      02-14-2005
Hi all,

I am currently struggling with a Tomcat issue. My version of the Tomcat is
3.2.4. When I send a redirect within the service method of my controller
servlet and have a return statement after it I get a page cannot be found in
the Internet Explorer. It isn't always occuring just ranomized. Any idea
where the problem could be? I guess it is related to my Tomcat version
3.2.4. When I add following code before calling return it seems to be
working.

response.sendRedirect(response.encodeRedirectURL(" ...."));

try {
Thread.sleep(1000);
} catch (InterruptedException intExc) {
...
}
return;
}

Thanks a lot,
Andreas


 
Reply With Quote
 
 
 
 
Andrea Desole
Guest
Posts: n/a
 
      02-14-2005
wow, that's an old version. You should really get a new one.
When you get page not found what page does it refer to? Is it the page
you are redirecting to? That would sound strange..
 
Reply With Quote
 
 
 
 
Andreas
Guest
Posts: n/a
 
      02-14-2005
Yes, it is exactly the page I am redirecting to. I have also debugged the
code several times and there was one interesting thing which I have
observed. When I set a breakpoint after sending the redirect and before
finishing the service method e.g. call return it is also working. I can see
that the page is displayed in my browser while being in the breakpoint of
the service method.

Any clue how to solve it any workaround for it?

By the way I am using this really old vesrion of Tomcat because of some
internal reasons.


 
Reply With Quote
 
Andrea Desole
Guest
Posts: n/a
 
      02-14-2005
Andreas wrote:
> Yes, it is exactly the page I am redirecting to. I have also debugged the
> code several times and there was one interesting thing which I have
> observed. When I set a breakpoint after sending the redirect and before
> finishing the service method e.g. call return it is also working. I can see
> that the page is displayed in my browser while being in the breakpoint of
> the service method.

well, this is strange. Whether you wait or not it shouldn't make a
difference, your destination url is always there. If the server sends a
redirect to the browser, then the server doesn't have control anymore:
the browser just asks for the new url.
Are you sure that your destination url works? Maybe you have some
threading issues that prevent the new page from being displayed? How
about redirecting to a dummy page, like java.sun.com?

>
> Any clue how to solve it any workaround for it?

well, I was thinking that there could be issues with how tomcat sends
the response (although I have worked with older versions of Tomcat and
never had this problem), and I was going to suggest to try to flush the
buffer. But if the browser gets the redirect correctly then Tomcat is
doing the job correctly.

>
> By the way I am using this really old vesrion of Tomcat because of some
> internal reasons.

I was hoping it was not depending on you
 
Reply With Quote
 
John C. Bollinger
Guest
Posts: n/a
 
      02-14-2005
Andreas wrote:

> Hi all,
>
> I am currently struggling with a Tomcat issue. My version of the Tomcat is
> 3.2.4. When I send a redirect within the service method of my controller
> servlet and have a return statement after it I get a page cannot be found in
> the Internet Explorer. It isn't always occuring just ranomized. Any idea
> where the problem could be? I guess it is related to my Tomcat version
> 3.2.4. When I add following code before calling return it seems to be
> working.
>
> response.sendRedirect(response.encodeRedirectURL(" ...."));
>
> try {
> Thread.sleep(1000);
> } catch (InterruptedException intExc) {
> ...
> }
> return;
> }


It should not be necessary to insert a delay before returning. It may
be that you are running into a bug in that decrepit version of Tomcat,
in which case you may find reference to it in Tomcat's Bugzilla
database. One alternative that occurred to me, however, is that your
controller servlet may not be thread safe (as it needs to be). I
haven't worked out an exact scenario for the behavior you described, but
it is certainly likely to result in a request for the redirect target
coming in before the thread in which the original request was processed
finishes with that request.

Wild guess: you're not trying to cache request objects or the
corresponding response objects past the end of request processing, are
you? That is absolutely not permitted and is known to in fact cause
bugs to manifest in webapps that attempt to do it. (This is in fact a
thread safety problem at its core.)

--
John Bollinger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Andreas
Guest
Posts: n/a
 
      02-15-2005
Hello Andrea,

I have to correct myself. It isn't the same URL. It is really a different
one. I thought all the time that it is the same but it isn't.

Do you have now any clue?

Thanks a lot for your help,
Andreas

"Andrea Desole" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> wow, that's an old version. You should really get a new one.
> When you get page not found what page does it refer to? Is it the page
> you are redirecting to? That would sound strange..



 
Reply With Quote
 
Andrea Desole
Guest
Posts: n/a
 
      02-15-2005
Andreas wrote:
> Hello Andrea,
>
> I have to correct myself. It isn't the same URL. It is really a different
> one. I thought all the time that it is the same but it isn't.


Interesting. And what url is it?

>
> Do you have now any clue?


Well, the idea of flushing the response content might help. In that way
the response is commited, including the redirect information. I also
remember that, with older versions of Tomcat, some strange problems were
occurring when mixing the servlet jars. Please check that your
application doesn't have its own servlet.jar or j2ee.jar or anything
like that. In one word, make sure that your application uses the J2EE
classes that come with Tomcat.
Also, you might want to check out what John Bollinger said.
An idea might also be to look at places in your code where redirect
works. If there aren't any, try to build a very simple application with
just one redirect, and see what happens. And, just to check if it's
tomcat, maybe you can try your code with a newer version of tomcat.
By the way, did you try to redirect to a simple external page? A page
that is not in your application and that works? What happens?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tomcat 6 / Apache 2.2 integration problem (no images / tomcat deploysto temp dir) Andi Java 5 03-20-2008 06:50 AM
Tomcat 5 runs what Tomcat 4 doesn't after modifying WEB.XML vunet.us@gmail.com Java 5 04-18-2007 12:41 AM
tomcat-maven-plugin problem - mvn is looking for org.apache.maven.plugins:maven-tomcat-plugin Marcin Cenkier Java 1 04-12-2006 08:00 PM
Problem with Tomcat Service when Tomcat Installation pathname has double byte characters Rakesh Pandit Java 0 07-12-2005 06:25 AM
Apache Tomcat 4.1.24: problem with Tomcat Administration link Christos Gravvanis Java 0 07-07-2004 05:21 PM



Advertisments