tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier (tomcat)>
Subject Re: Is there a way for code running on Tomcat 7+ to determine the URL of the Web App it's running under?
Date Fri, 12 Feb 2016 20:10:00 GMT
On 12.02.2016 20:49, Dougherty, Gregory T., M.S. wrote:
> You can honestly tell who¹s calling you, since you can throw an exception,
> catch it, then look at the stack trace.
> If you have an object, you can get its class, you can get what methods it
> implements, and you can get its parent class and recurse.
> So that should let you figure out which class will be implementing the
> emthod you¹re calling, unless I¹m totally confused.

I can be confused easily too, in matters Java.
But let's just speculate, and someone undoubtedly would correct me if I'm wrong.
1) you do not necessarily trust the code which is (directly) calling you.  But you would 
trust it if you were sure that it is the original Tomcat code.
2) if I remember correctly, a HttpServletRequest object is immutable, so nobody can have 
modified the original data of the request, as it came in and was parsed by Tomcat.
3) What they could do however, is wrap the original object into another, and override the

methods so that they would return other data than the original when you call getRequestURL
4) but you can climb up the object hierarchy, until you find the original (Tomcat) 
HttpServletRequest object and its methods

yes ?
Then I would imagine that there must be a way for you to retrieve the data as provided by

the original HttpServletRequest getRequestURL, no ?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message