Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

url rewrite filter

 
Miran Cvenkel
Ranch Hand
Posts: 196
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is there a way ro intercept what was sourceURL, when arriwing to target url ?

Referer does not work.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpServletRequest has several methods to get the original URL the client requested. This includes getRequestURI(), getPathInfo() and getQueryString().
 
Paul Clapham
Sheriff
Pie
Posts: 20750
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If "sourceURL" means "the URL which was used to make this request", then the request object has methods to get that. I don't think there's a method which gets you the whole thing all at once, but (I'm not looking at the documentation right now) I recall there is getHost() and getPort(), and there are others to get the other parts of the URL.
 
Miran Cvenkel
Ranch Hand
Posts: 196
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, no luck with any of that , but I took a peak at request object at debugger and it contains array naned specialAttributes with 9 elements , of which 5 and 7 contains inf on 'sourceURL' thing.

How to get that out, there is no request,getSpecialAttribute or something like that ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miran Cvenkel wrote:So, no luck with any of that , but I took a peak at request object at debugger

Screw the debugger, look at the javadoc!
 
Miran Cvenkel
Ranch Hand
Posts: 196
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Figured it out, thanks for help.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does that have to do with the URL?
 
Miran Cvenkel
Ranch Hand
Posts: 196
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one of those is 'javax.servlet.forward.request_uri'
 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:HttpServletRequest has several methods to get the original URL the client requested. This includes getRequestURI(), getPathInfo() and getQueryString().

The first reply gave you your answer. Why dig through attribute values, when you can simply call request.getRequestURI() ?
 
Miran Cvenkel
Ranch Hand
Posts: 196
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because that returns 'targetUrl' instead of 'sourceURL' which I'm after.
 
Victor M. Pereira
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miran Cvenkel wrote:Figured it out, thanks for help.



This is interesting, but wouldn't this discovery mean that it only applies to your developing server implementation of HttpServletRequest?

My work around would be sending a cookie that has the last sourceURL. A Filter could do this; however, if he disabled cookies I would be in a big problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic