| Author |
How to get the intended URL from a request
|
Rajesh Khan
Ranch Hand
Joined: Oct 16, 2011
Posts: 230
|
|
Hi my filter is managing permissions for different pages. Is it possible to get the url destination of the request ?? If so how ??
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
|
If I understand you correctly, you can use getRequestURI method to get, and possibly save it for later use.
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
Rajesh Khan
Ranch Hand
Joined: Oct 16, 2011
Posts: 230
|
|
Bosun Bello wrote:If I understand you correctly, you can use getRequestURI method to get, and possibly save it for later use.
It seems that method is not available in
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56162
|
|
|
Sure it is. You need to cast the request instance to HttpServletRequest.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Rajesh Khan
Ranch Hand
Joined: Oct 16, 2011
Posts: 230
|
|
Bear Bibeault wrote:Sure it is. You need to cast the request instance to HttpServletRequest.
Thanks that did the trick
|
 |
Rajesh Khan
Ranch Hand
Joined: Oct 16, 2011
Posts: 230
|
|
Okay so with a little debugging and trial and error i realized that the following works (both filter and servlet)
But the following just throws an exception (I Wonder what the difference is)
Exception is
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
|
In the first case, you are casting, however in the second, you are calling a method on a variable that is null. Hence, the reason for the null pointer. With casting, if what you are casting returns null, your fast will return exactly that.
|
 |
Rajesh Khan
Ranch Hand
Joined: Oct 16, 2011
Posts: 230
|
|
Bosun Bello wrote:In the first case, you are casting, however in the second, you are calling a method on a variable that is null. Hence, the reason for the null pointer. With casting, if what you are casting returns null, your fast will return exactly that.
That makes sense.. thanks..
|
 |
 |
|
|
subject: How to get the intended URL from a request
|
|
|