Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Http redirect question.

 
Yogendra Joshi
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all ,

I am new to Struts and its really fun working with Struts. It is very robust and effective.

I have just used <logic:redirect/> tag and faced a problem which i myself created. It says Http Redirect request failed. The reason being i have 2 pages , index and success.jsp , What i have done is i have wrote <logic:redirect href="/TestStruts/success.jsp"> in index.jsp and <logic:redirect href="/TestStruts/index.jsp"> in success.jsp.

I know this is silly and this is never going to be used in any used application in this world. What i was expecting that it would give me a StackOverFlow error , instead it said "HTTP REDIRECT REQUEST FAILED". Can someone let me know why has this happened ? Because as this is an loop and recursive it should have thrown StackOverflowError.

Any help is much appreciated. Thanks in advance for your sincere comments and advice.

Yogendra Joshi.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The <logic:redirect> tag performs an HttpServletResponse.sendRedirect() call to the URL you provide. It must be the first and only instruction that produces output executed by your JSP. Otherwise, it will fail. I suspect it may be failing because your JSP attempts to produce other output before executing this tag.

Regarding your expectations that it would produce a stack overflow, that is not accurate. A redirect is an instruction sent to the browser to redirect to a different page. Since this process is external to the JVM, it would not cause a stack overflow, but simply cause your browser to continually load one page and then the other.
[ August 31, 2006: Message edited by: Merrill Higginson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic