• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with redirect and a parameter  RSS feed

 
Andrew McLaren
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem with response.sendRedirect. If I hardcode in the parameter (response.sendRedirect(response.encodeRedirectURL("http://localhost:8080/CRNAddSignon/test.jsp")); , it works fine.

But if I try to use a variable for that parameter, it doesn't seem to
work.
String redirect = request.getParameter("redir");
response.sendRedirect(response.encodeRedirectURL(redirect));
Gives me this:
The requested resource (/CRNAddSignon/"http://localhost:8080/CRNAddSignon/test.jsp") is not available.

It appears to be treating the url as relative the second way, and I just don't understand why!

Andrew

[ June 30, 2005: Message edited by: Andrew McLaren ]
[ June 30, 2005: Message edited by: Andrew McLaren ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/CRNAddSignon/"http://localhost:8080/CRNAddSignon/test.jsp"


If this is indeed the string that is being passed to sendRedirect, it's not a valid URL.
 
Andrew McLaren
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoops, sorry, guess I left out that useful bit of info. The
String redirect = request.getParameter("redir");
returns this:
"http://localhost:8080/CRNAddSignon/test.jsp".

I verified this by printing the redirect variable to the console. Even wierder, if I do
String redirect = "http://localhost:8080/CRNAddSignon/test.jsp"
it works fine.
 
Priti Shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try to print output of

response.encodeRedirectURL(redirect) ??
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you are saying that passing the same string as a literal or as a variable reference changes how it works?

That is not possible. There is something else at work here. Verify that what you are passing to sendRedirect is what you expect in both cases.

Btw, what servlet container are you using?
[ June 30, 2005: Message edited by: Bear Bibeault ]
 
Andrew McLaren
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha! Got it now. My URL had "s around the redirect parameter, so I was actually trying to redirect to "http://localhost:8080/CRNAddSignon/test.jsp", which for whatever reason got treated as a relative URL, so the /CRNAddSignon/ bit was being appended on to the front.

Thanks!

Andrew
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!