aspose file tools*
The moose likes Servlets and the fly likes url rewrite filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "url rewrite filter" Watch "url rewrite filter" New topic
Author

url rewrite filter

Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 147


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

Referer does not work.


Searchable nature photo gallery: http://agrozoo.net/jsp/Galery.jsp?l2=en
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19692
    
  20

HttpServletRequest has several methods to get the original URL the client requested. This includes getRequestURI(), getPathInfo() and getQueryString().


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18563
    
    8

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

Joined: Nov 23, 2010
Posts: 147
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

Joined: Jan 10, 2002
Posts: 61180
    
  66

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!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 147
Figured it out, thanks for help.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

What does that have to do with the URL?
Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 147
one of those is 'javax.servlet.forward.request_uri'
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

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() ?


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 147
because that returns 'targetUrl' instead of 'sourceURL' which I'm after.
Victor M. Pereira
Ranch Hand

Joined: Mar 02, 2012
Posts: 50
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.


regards,
Victor M. Pereira
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: url rewrite filter