• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception: Server redirected too many times (20)

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am working on a standalone application which reads the data from a web page with the help of URL and automatically writes it to an Excel sheet at regular intervals.
This application is helped by another single sign-on application and requires a pair of username/password for accessing webpage's details.
But I am getting the exception: "java.net.ProtocolException: Server redirected too many times (20)"
What is the meaning of this exception?wheather it is showing an authentication problem or something else?I have googled it lots of time but I havn't got any satisfactory answer for this problem!
Also tell me how it can be removed?Does it requires code changes at server side also?
 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check you server program if it is properly coded. There could be loops or non-properly-terminated http request methods. If the code is small, you can post it here.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The most likely reason is that one of the involved servers sets cookies, and the other one doesn't receive them. That's no surprise, as the code you posted doesn't handle cookies at all. See this article for how to do that.
 
Ankit Tripathi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for replies,Ulf and Jesus......
 
Ankit Tripathi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jesus and Ulf,
I am pasting here server side code.There are total four classes in server side code(three servlets,one java class).main servlets of server side code are RedirectToIdpServlet and RedirectToSpServlet,As their names are telling I am suspecting some loop or redirection in code but exactly not getting "where this loop is and how it would be removed",as I am not aware of server side appliaction,seeing it first time.I am pasting the codes for "RedirectToIdpServlet" and "RedirectToSpServlet" here.The only thing I can tell is, "The client request first goes to RedirectToSpServlet".
Please see these code snippets and tell if any suspected thing is found and how it can be resolved.

RedirectToIdpServlet



RedirectToSpServlet


 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am pasting the codes for "RedirectToIdpServlet" ... here.


Not yet.

What is "registerPrincipalURL" - is that a destination that's under your control?

Have you used an HTTP monitor (like the Firefox extension LiveHttpHeaders, or WireShark) to investigate what's going on?
 
Ankit Tripathi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I have posted the code.I am not aware about the functionality of this cod, somebody else has developed this code.
From the code of "RedirectToSpServlet",I guess, it should be part of redirected URL(Originally requested URL from user's side+registerPrincipalURL).
I havn't used any of the tools.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I think I have posted the code.


You posted a class called "RequestHack" which is not a servlet.

I am not aware about the functionality of this cod, somebody else has developed this code.


Have you been in touch with that person yet? That would seem the logical first step.

I havn't used any of the tools.


Then I advise to start with that so you get a better understanding of what's going on at runtime, like which URL redirects to which other one in which sequence.

From the code of "RedirectToSpServlet",I guess, it should be part of redirected URL


That much is obvious. But unless you know which piece of code can redirect to *where* under *which* circumstances, AND you know what is exactly happening at runtime, there's not much chance of this getting resolved, certainly not by anyone in this forum who doesn't have access to any of that information.
 
Ankit Tripathi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for inconvenience Ulf,The code for RedirectToIdpServlet has been given below-



I am not in touch with concerned person at present.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. We still don't know what the values of "idpURL" and "registerPrincipalURL" are, and we don't know which URLs these two servlets are mapped to, though. Be sure to let us know the values of the query parameters as well, since those are used to determine to where the redirect should happen.

We also don't know between which URLs the redirects occurs, but I'm assuming you're working on finding that out. Should be easy using the tools I mentioned; the Firefox extension is quite simple to use.

Let us know once you have all this information, and we can take it from there.
 
Ankit Tripathi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Ulf,Surely I'll notify as I finish.
 
Author
Posts: 131
7
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for this posting. I recently had the same error suddenly occur reading a website I have been reading for years. The suggestion about the CookieManager resolved the error.
 
reply
    Bookmark Topic Watch Topic
  • New Topic