rnicholus
asked on
"Server redirected too many times (20)" problem
I'm trying to open a URL using HttpsURLConnection, but once in a while I got this message: "Server redirected too many times (20)". What can I do about this? Is this usually something wrong with the java code or the website setup?
Thanks in advance for the help
Thanks in advance for the help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yes. there could be 2 cases:
1. server needs a cookie that client is not sending and server redirects (after adding some cookies) to some page. When client ignores the second page - it leads to infinite redirection.
2. The server is not configured correctly. Like when we try to download page x.html, it redirects to y.html. When y.html is asked it redirects to x.html
1. server needs a cookie that client is not sending and server redirects (after adding some cookies) to some page. When client ignores the second page - it leads to infinite redirection.
2. The server is not configured correctly. Like when we try to download page x.html, it redirects to y.html. When y.html is asked it redirects to x.html
ASKER
Ajay-Singh,
1. What do you mean by "client ignores the second page."?
2. If it happens very random and only once in a while, isn't it unlikely that the server actually needs the cookie?
Thanks for the on-going help.
1. What do you mean by "client ignores the second page."?
2. If it happens very random and only once in a while, isn't it unlikely that the server actually needs the cookie?
Thanks for the on-going help.
> What do you mean by "client ignores the second page."?
sorry about typo - i mean when client ignore the cookie sent my the server in the redirection response.
sorry about typo - i mean when client ignore the cookie sent my the server in the redirection response.
> If it happens very random and only once in a while, isn't it unlikely
> that the server actually needs the cookie?
and are you able to download this page consistently from standard browsers (like IE)
> that the server actually needs the cookie?
and are you able to download this page consistently from standard browsers (like IE)
ASKER
One of my coworker have tried to access the page manually when the "Server redirected too many times (20)" message occurs in the program console output.
He said that he tried to login several times using username and pwd that has been provided to us but the page rejected the login.
And then it prints the exception below.
I'm not sure whether this is caused by my friends trying to login too many times or could be something else.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx ception
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 58)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:301)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:248)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 856)
..........
root cause
java.lang.NullPointerExcep tion
org.apache.jsp.error_jsp._ jspService (error_jsp .java:415)
org.apache.jasper.runtime. HttpJspBas e.service( HttpJspBas e.java:133 )
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 856)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 11)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:301)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:248)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 856)
..........
He said that he tried to login several times using username and pwd that has been provided to us but the page rejected the login.
And then it prints the exception below.
I'm not sure whether this is caused by my friends trying to login too many times or could be something else.
--------------------------
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
..........
root cause
java.lang.NullPointerExcep
org.apache.jsp.error_jsp._
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
..........
by any change you jsp redirects based on some condition? can you post that part of the jsp code?
ASKER
That JSP exception is not coming from my program. What I have is a console-based program that access this page.
The JSP exception is what my friend see in the browser (I think he used Internet Explorer) when trying to access that page.
The JSP exception is what my friend see in the browser (I think he used Internet Explorer) when trying to access that page.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
and this may also help you to increase the max redirects!
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4458085
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4458085
ASKER
ksivananth,
could you please explain to me what your code will do?
astorer,
i have seen the link before. i'm currently running the code the link provides -> just to know what URL I am being redirected to.
could you please explain to me what your code will do?
astorer,
i have seen the link before. i'm currently running the code the link provides -> just to know what URL I am being redirected to.
It checks if the request is redirected, if so, makes a connection to the redirected URL! If your URL redirects more than 20 times, you may consider using the maxRedirects property.
but did u try that?
ASKER
I will try this code. I'll let you know
ASKER
ksivananth,
i tried your code and when the exception occurs, it doesn't go inside the while loop.
any advice?
thanks
i tried your code and when the exception occurs, it doesn't go inside the while loop.
any advice?
thanks
>>i tried your code and when the exception occurs, it doesn't go inside the while loop.
what exception?
is it the "Server redirected too many times (20)"? if so, try set the "http.maxRedirects" property to large value!
what exception?
is it the "Server redirected too many times (20)"? if so, try set the "http.maxRedirects" property to large value!
Check this out. Its the similar problem I face and here is the solution to it...
http://jaykhimani.blogspot.com/2009/04/problem-with-jdk-and-network-proxy.html
http://jaykhimani.blogspot.com/2009/04/problem-with-jdk-and-network-proxy.html
ASKER
Thanks for your reply.
I don't understand how this is related to the cookies server needs. Could you please explain more?