• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

How to get the intended URL from a request  RSS feed

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi my filter is managing permissions for different pages. Is it possible to get the url destination of the request ?? If so how ??
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand you correctly, you can use getRequestURI method to get, and possibly save it for later use.
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure it is. You need to cast the request instance to HttpServletRequest.
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Sure it is. You need to cast the request instance to HttpServletRequest.


Thanks that did the trick
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1512
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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..
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!