File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes response.sendRedirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "response.sendRedirect" Watch "response.sendRedirect" New topic
Author

response.sendRedirect

Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 149
The point beeing, I renamed a.jsp to b.jsp, and want google to find it anyway.

in jsp



in JspStart



1. If I said redirect, why there must be return after that ? (othervise programm goes down executing things)
2. The first redirect that occurs in that manner --> java emidiately starts eating 100% CPU and it does not let go, luckely multicore processor, so it does not hang ?

Searchable nature photo gallery: http://agrozoo.net/jsp/Galery.jsp?l2=en
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

1. If you are going to redirect, it doesn't make any sense to continue emitting output that will never be seen.

2. Use a profiler tool to find out where your performance issue is.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18992
    
    8

1. It's a basic rule of the Java language. Statements are executed one after the other. So when control returns from the sendRedirect() method, it continues on to the next statement.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

The first redirect that occurs in that manner --> java emidiately starts eating 100% CPU and it does not let go, luckely multicore processor, so it does not hang ?


It is only a matter of time before all cores are consumed.

It looks like what you want is to rather send a HTTP 301 / 302 response status code ? Have you looked into that ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 149
so if I go with last advice:

example: http://agrozoo.net/jsp/Tools.jsp?p0=Thesaurus&p3=67008d1cb23311df864f001cc081f832
is redirected to new adress with this code:



it works but this tester http://www.webconfs.com/redirect-check.php says it is not OK.
Is it bad tester or I'm doing something wrong ?

Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

Miran Cvenkel wrote:so if I go with last advice:

example: http://agrozoo.net/jsp/Tools.jsp?p0=Thesaurus&p3=67008d1cb23311df864f001cc081f832
is redirected to new adress with this code:



it works but this tester http://www.webconfs.com/redirect-check.php says it is not OK.
Is it bad tester or I'm doing something wrong ?



The tester probably tries to use your relative URL in the Location header and fails. SEO wise, I am not sure if that is good or bad. You can research that and make a decision.
Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 149


Missing return, now tester is happy. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: response.sendRedirect