Re: Expression Language ${initParam.whatever} not working

2020-02-10 Thread Richard Monson-Haefel
Thanks, Mark. Your explanation was good but the code didn't do it.

On Mon, Feb 10, 2020 at 12:10 PM Mark Thomas  wrote:

> On 10/02/2020 18:03, Richard Monson-Haefel wrote:
> > Hi Simon,
> >
> > Thanks for the response but I don't think that is the issue. I can use
> the
> >  instead, but I want to use the initParam for the JSP page
> > which is named and mapped in the  element.  Perhaps I'm still
> > missing something.
>
> The EL implicit object initParam holds the *ServletConext*'s init
> params, not the Servlet's.
>
> You probably want something like (untested)
>
> ${ pageContext.servletConfig.initParameter("greeting_color") }
>
> Mark
>
>
> >
> > On Mon, Feb 10, 2020 at 12:00 PM Simon Funnell 
> > wrote:
> >
> >> In your web.xml you want:
> >>
> >> 
> >> greeting_color
> >> green
> >>   
> >>
> >> I think you have defined an initialization parameter for the servlet,
> not
> >> the context.
> >>
> >> On Mon, 10 Feb 2020 at 17:54, Richard Monson-Haefel <
> >> monsonhae...@gmail.com>
> >> wrote:
> >>
> >>> Hi,
> >>>
> >>> Tomcat version: 9.0.30
> >>> Operating System: macOS 10.15.2
> >>>
> >>> While I can access my initParam vis a JSP scriptlet I cannot access the
> >>> same initial paramter EL expression.
> >>>
> >>> Here is the JSP code I'm using
> >>>
> >>> 
> >>>   
> >>> 
> >>>  >>> %>">Hello ${param.name} from
> hello.jsp
> >>>
> >>> 
> >>> color is ${initParam["greeting_color"]}
> >>>   
> >>> 
> >>>
> >>> Here is my web.xml declaring the initial parameters
> >>>
> >>> http://xmlns.jcp.org/xml/ns/javaee;
> >>>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
> >>>   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
> >>>
> http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd
> >> "
> >>>   version="4.0"
> >>>   metadata-complete="true">
> >>>
> >>>
> >>>   
> >>>   
> >>>   HiJsp
> >>>   /hello.jsp
> >>>   
> >>>   greeting_color
> >>>   green
> >>>   
> >>>   
> >>>   
> >>>   HiJsp
> >>>   /hola/*
> >>>   
> >>> 
> >>>
> >>> Here is the output (source)
> >>>
> >>> 
> >>> 
> >>> 
> >>> Hello richard from
> >>> hello.jsp
> >>> 
> >>> color is
> >>> 
> >>> 
> >>>
> >>> I don't understand why the JSP expression <%= %> works but the EL
> >>> expression ${ } doesn't.  I've tried many variations and other EL
> >> implicit
> >>> objects I've tried worked fine.
> >>>
> >>> What am I missing?
> >>>
> >>> The WAR is attached for your convenience.
> >>>
> >>>
> >>>
> >>> --
> >>> Richard Monson-Haefel
> >>> https://twitter.com/rmonson
> >>> https://www.linkedin.com/in/monsonhaefel/
> >>>
> >>> -
> >>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> >>> For additional commands, e-mail: users-h...@tomcat.apache.org
> >>
> >
> >
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>

-- 
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/


Re: Expression Language ${initParam.whatever} not working

2020-02-10 Thread Mark Thomas
On 10/02/2020 18:03, Richard Monson-Haefel wrote:
> Hi Simon,
> 
> Thanks for the response but I don't think that is the issue. I can use the
>  instead, but I want to use the initParam for the JSP page
> which is named and mapped in the  element.  Perhaps I'm still
> missing something.

The EL implicit object initParam holds the *ServletConext*'s init
params, not the Servlet's.

You probably want something like (untested)

${ pageContext.servletConfig.initParameter("greeting_color") }

Mark


> 
> On Mon, Feb 10, 2020 at 12:00 PM Simon Funnell 
> wrote:
> 
>> In your web.xml you want:
>>
>> 
>> greeting_color
>> green
>>   
>>
>> I think you have defined an initialization parameter for the servlet, not
>> the context.
>>
>> On Mon, 10 Feb 2020 at 17:54, Richard Monson-Haefel <
>> monsonhae...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> Tomcat version: 9.0.30
>>> Operating System: macOS 10.15.2
>>>
>>> While I can access my initParam vis a JSP scriptlet I cannot access the
>>> same initial paramter EL expression.
>>>
>>> Here is the JSP code I'm using
>>>
>>> 
>>>   
>>> 
>>> >> %>">Hello ${param.name} from hello.jsp
>>>
>>> 
>>> color is ${initParam["greeting_color"]}
>>>   
>>> 
>>>
>>> Here is my web.xml declaring the initial parameters
>>>
>>> http://xmlns.jcp.org/xml/ns/javaee;
>>>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
>>>   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>>>   http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd
>> "
>>>   version="4.0"
>>>   metadata-complete="true">
>>>
>>>
>>>   
>>>   
>>>   HiJsp
>>>   /hello.jsp
>>>   
>>>   greeting_color
>>>   green
>>>   
>>>   
>>>   
>>>   HiJsp
>>>   /hola/*
>>>   
>>> 
>>>
>>> Here is the output (source)
>>>
>>> 
>>> 
>>> 
>>> Hello richard from
>>> hello.jsp
>>> 
>>> color is
>>> 
>>> 
>>>
>>> I don't understand why the JSP expression <%= %> works but the EL
>>> expression ${ } doesn't.  I've tried many variations and other EL
>> implicit
>>> objects I've tried worked fine.
>>>
>>> What am I missing?
>>>
>>> The WAR is attached for your convenience.
>>>
>>>
>>>
>>> --
>>> Richard Monson-Haefel
>>> https://twitter.com/rmonson
>>> https://www.linkedin.com/in/monsonhaefel/
>>>
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
> 
> 


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: [OT] HttpServletRequest.getRemoteAddr() sometimes returns NULL on Tomcat 9.0.30 and HTTP/2 secure requests

2020-02-10 Thread Manuel Dominguez Sarmiento

Hi Christopher, please see below:


1) The Tomcat valves operate on all webapps. We only need/require
this for one particular webapp without affecting the others.

Not true; see Konstantin's response.
Yes, I realized per-context valve configuration was possible after I 
sent my original email.



2) The code has been simplified for illustration purposes. Besides
X-Forwarded-For, we detect and work around many other custom
external mobile proxies which do not use X-Forwarded-For and
require custom Geolocation code to detect the ISP and connection
type (Google Compression Proxy, Nokia OVI, Novarra, Lotus Flare,
Opera Mini, Opera Max, Samsung Max, etc.) - this kind of
customization is not possible without custom code.

Interesting. Is this something you think would be widely useful
Not sure how useful it would be to other users. We are a fairly 
specialized shop running platforms for mobile carriers, so mobile 
carrier detection, MSISDN header enrichment, detecting whether users are 
on a real 3G/4G network or through a modem, hotspot or proxy, etc. are a 
major concern for us, but I don't believe most users would care about this.



and/or would be willing to share with the community?

We'd be willing to share our code, however see my comments above.


If it's a fast-moving
target (e.g. new public proxies are popping-up all the time, or
existing proxies keep changing their configuration requirements) then
maybe it's not a great fit for a stable product like Tomcat.
Most of our proxy detection logic works by checking geolocation data 
from trusted, paid sources (MaxMind and Digital Element/NetAcuity) so 
even if the logic is simpe, it requires fresh, updated data from a 
trusted third-party to be of any use.


On the other hand, some of the proxy detection logic instead depends on 
proprietary header analysis (for instance, Opera Mini inserts many 
X-OperaMini- prefixed headers).



On the other hand, if it could be configured relatively easily (like
with a "proxy definitions" file or something), then it could still be
very valuable even with a simple or default configuration which only
supports some very large proxies (e.g. Akamai, CloudFront, CloudFlare,
etc.).
This is only useful for small, well-known partner proxies that are 
supposed to notify us if their IP addresses change.
But major proxies change their IP ranges all the time. So, again, this 
would not really be useful without the third-party geolocation data.



This filter is not meant for detecting internal proxies within our
control (such as Apache front ends or load balancers), but rather
public proxies which are "transparently" (not really) used via
some mobile devices and services.

Does it matter whether these are "internal" versus "external" proxies?
The only real difference is the IP-range of the proxy, right?
No, that's not the only difference. Some proxies introduce non-standard 
behaviour, even if they advertise themselves as "trasparent":
- Novarra proxy transcodes HTML for small screens (this proxy is 
obsolete, but is a prime example of non-transparency)
- Opera Mini does all sorts of fancy things to compress responses: it 
coalesces HTML, images, and JavaScript payloads to minimize the number 
of streams; modifies HTML to fit devices with small screens and/or low 
memory/CPU resources, etc.
- Chrome Compression Proxy (aka "Data Saver mode") is fairly 
transparent, but there are many caveats. In particular, MSISDN header 
enrichment breaks, which is a major issue for services we manage for 
mobile carriers. See 
https://developer.chrome.com/multidevice/data-compression-for-isps for 
more details.

- etc.


It doesn't matter whether you control the proxy or it's an external
service: you still have to secure and validate the connection in the
same ways, and take the same action(s) on the server-end where you
trust the information being presented.

See comments above.

*Manuel Dominguez Sarmiento*


Re: Expression Language ${initParam.whatever} not working

2020-02-10 Thread Richard Monson-Haefel
Hi Simon,

Thanks for the response but I don't think that is the issue. I can use the
 instead, but I want to use the initParam for the JSP page
which is named and mapped in the  element.  Perhaps I'm still
missing something.

On Mon, Feb 10, 2020 at 12:00 PM Simon Funnell 
wrote:

> In your web.xml you want:
>
> 
> greeting_color
> green
>   
>
> I think you have defined an initialization parameter for the servlet, not
> the context.
>
> On Mon, 10 Feb 2020 at 17:54, Richard Monson-Haefel <
> monsonhae...@gmail.com>
> wrote:
>
> > Hi,
> >
> > Tomcat version: 9.0.30
> > Operating System: macOS 10.15.2
> >
> > While I can access my initParam vis a JSP scriptlet I cannot access the
> > same initial paramter EL expression.
> >
> > Here is the JSP code I'm using
> >
> > 
> >   
> > 
> >  > %>">Hello ${param.name} from hello.jsp
> >
> > 
> > color is ${initParam["greeting_color"]}
> >   
> > 
> >
> > Here is my web.xml declaring the initial parameters
> >
> > http://xmlns.jcp.org/xml/ns/javaee;
> >   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
> >   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
> >   http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd
> "
> >   version="4.0"
> >   metadata-complete="true">
> >
> >
> >   
> >   
> >   HiJsp
> >   /hello.jsp
> >   
> >   greeting_color
> >   green
> >   
> >   
> >   
> >   HiJsp
> >   /hola/*
> >   
> > 
> >
> > Here is the output (source)
> >
> > 
> > 
> > 
> > Hello richard from
> > hello.jsp
> > 
> > color is
> > 
> > 
> >
> > I don't understand why the JSP expression <%= %> works but the EL
> > expression ${ } doesn't.  I've tried many variations and other EL
> implicit
> > objects I've tried worked fine.
> >
> > What am I missing?
> >
> > The WAR is attached for your convenience.
> >
> >
> >
> > --
> > Richard Monson-Haefel
> > https://twitter.com/rmonson
> > https://www.linkedin.com/in/monsonhaefel/
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: users-h...@tomcat.apache.org
>


-- 
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/


Re: Expression Language ${initParam.whatever} not working

2020-02-10 Thread Simon Funnell
In your web.xml you want:


greeting_color
green
  

I think you have defined an initialization parameter for the servlet, not
the context.

On Mon, 10 Feb 2020 at 17:54, Richard Monson-Haefel 
wrote:

> Hi,
>
> Tomcat version: 9.0.30
> Operating System: macOS 10.15.2
>
> While I can access my initParam vis a JSP scriptlet I cannot access the
> same initial paramter EL expression.
>
> Here is the JSP code I'm using
>
> 
>   
> 
>  %>">Hello ${param.name} from hello.jsp
>
> 
> color is ${initParam["greeting_color"]}
>   
> 
>
> Here is my web.xml declaring the initial parameters
>
> http://xmlns.jcp.org/xml/ns/javaee;
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
>   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>   http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd;
>   version="4.0"
>   metadata-complete="true">
>
>
>   
>   
>   HiJsp
>   /hello.jsp
>   
>   greeting_color
>   green
>   
>   
>   
>   HiJsp
>   /hola/*
>   
> 
>
> Here is the output (source)
>
> 
> 
> 
> Hello richard from
> hello.jsp
> 
> color is
> 
> 
>
> I don't understand why the JSP expression <%= %> works but the EL
> expression ${ } doesn't.  I've tried many variations and other EL implicit
> objects I've tried worked fine.
>
> What am I missing?
>
> The WAR is attached for your convenience.
>
>
>
> --
> Richard Monson-Haefel
> https://twitter.com/rmonson
> https://www.linkedin.com/in/monsonhaefel/
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org


Expression Language ${initParam.whatever} not working

2020-02-10 Thread Richard Monson-Haefel
Hi,

Tomcat version: 9.0.30
Operating System: macOS 10.15.2

While I can access my initParam vis a JSP scriptlet I cannot access the
same initial paramter EL expression.

Here is the JSP code I'm using


  

">Hello ${param.name} from hello.jsp


color is ${initParam["greeting_color"]}
  


Here is my web.xml declaring the initial parameters

http://xmlns.jcp.org/xml/ns/javaee;
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
  http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd;
  version="4.0"
  metadata-complete="true">


  
  
  HiJsp
  /hello.jsp
  
  greeting_color
  green
  
  
  
  HiJsp
  /hola/*
  


Here is the output (source)




Hello richard from hello.jsp


color is



I don't understand why the JSP expression <%= %> works but the EL
expression ${ } doesn't.  I've tried many variations and other EL implicit
objects I've tried worked fine.

What am I missing?

The WAR is attached for your convenience.



-- 
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Re: HTTP error response payload

2020-02-10 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Saurav,

On 2/8/20 1:47 AM, Saurav Sarkar wrote:
> Hi All,
> 
> Through tomcat access valve i can view the HTTP request url
> ,response code etc.
> 
> But i can not view the error response being sent in the form of
> JSON payload.
> 
> Is their any valve/filter/ any other setting on tomcat level which
> can enable this or applications (server and clients) themselves
> have to log it.

Are you asking if you can log the response body to a log file?

There are no components which ship with Tomcat that can do that
directly, but you could write your own Filter to siphon-off a copy of
the response to a file somewhere. Be aware that the log file is likely
to grow enormously in a short period of time. You may want to put some
kind of filtering on which responses you want to log.

- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5BbtgACgkQHPApP6U8
pFglDg//cv4BxQ/hgmQDl3LFHxSWBxuBJTMIOSlKZ8NuFefxMF9dDwquWKnGAZ8q
7bKA1GXBJSZa6GMEgjmk4keIeaYasli7K3+wxpt61eAxg3GQwCnW1UGZ9BqStDQS
q68UQRmohNVvMIcjlhd1n7Si+Xh00C9go84pwlGJ1DpydDn6ziwam1TYLA/l2gI3
Dr1r4BIbj8oMSwr/Pd+80EZu/Is6dI617Jh5KjGZE+HGHnCum7tBySnRCyd+yktg
w+mjikWslczu21IzoOkvtZDfwFC1iSBK3MOO7JWOHCCRsjFTREL/0LjaP0t6kp7A
EtxTWAKBs4eorwyXcgWK3zAazgsIzbnhWPg9Rlc/188wcKG2cPldW3amJBsziOjQ
TGJ5M5Uyt37xvP0JE4Rz9TwJjm2bx4Bnjsa7jd/N+8PtY9Zr2rqb75vECWKw03tz
TBe65t+XFNyaKqtS7nEDaFkHM/NyaQo5YGXtAza4yTiz2xb1GK0j6R37XrtgC9aL
vFPzy8mUy7hi+U4Ygi+irsavH+qq/vFH+pSoE8qAb1lTnp3VBsU7JI37J3f5Au0i
5TeuOqEolQK4WMShMfV83g2R5M9Cv4PZWl2yyI7N3PnnTYUYKWwbCiQ/hNGTgkQW
p7BpftCQhaPs/UZ2pUl2ShNOJO6KYcGeA7rhXCnLPZtFk3nGiMQ=
=XLSH
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Question on HttpSession investigation

2020-02-10 Thread Luis Rodríguez Fernández
Hello M. Manna,

I do think HttpSession.getAttributeNames(), HttpSession.getAttribute(name)
should be good enough for debugging your issue. You can have a look at the
good and classic examples servlet [1] included in every tomcat distribution.

If you want to be sure what server is serving your request you can print as
well the server's IP or hostname
using Inet4Address.getLocalHost().getHostName(). Or even simpler you can
add a system property like -Dserver.name=serverA and print it.

Hope it helps,

Luis

[1]
https://github.com/apache/tomcat/blob/master/webapps/examples/WEB-INF/classes/SessionExample.java









El lun., 10 feb. 2020 a las 0:32, M. Manna () escribió:

> Hello,
>
> I apologise in advance if the answer is obvious for this question. We are
> trying to investigate (in an isolated cluster) whether our session
> attributes are getting lost somewhere in the process.
>
> The issue is that we are setting it at a JSP Tag Level, however, when we do
> an AJAX request back to the same server, the session doesn't have the
> attribute set by the tag. Since it's two different servers, we would like
> to check using JMX whether this is present somewhere in session. Debugging
> has not resulted into a successful outcome.
>
> We appreciate if this is not possible, but just wanted to check if tomcat
> currently emits anything related to this.
>
> Regards,
>


-- 

"Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."

- Samuel Beckett


Re: Installing a program designed for Tomcat 5.5 on Tomcat 9

2020-02-10 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Mark,

On 2/6/20 6:01 PM, Mark Thomas wrote:
> On 06/02/2020 20:32, Shane Johnson wrote:
>> I am currently trying to install a program designed to operate on
>> Win XP 32 and earlier on to a Win 10 environment. The program
>> extracts to the Shared and Webapps folders of Tomcat 5.5 and uses
>> a SQL database. After converting the database and installing it
>> on SQL 2017 I added the JDBC connector and downloaded and
>> installed tomcat 9 only to find there is no shared folder to 
>> extract the shared files to. Any suggestions?
> 
> There are several options but the simplest is put anything
> extracted to shared in the lib directory.

IMHO, the proper place to move libraries that were in an old "shared"
folder on a previous installation is the application's own
WEB-INF/lib/ directory, rather than Tomcat's top-level lib directory.

If any of those libraries conflicts with anything provided by Tomcat,
there may be problems with the server if you put them into lib/.
Instead, if you put them into WEB-INF/lib/, then the server will
isolate them to that one application and they will not pollute the
rest of the server.

- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5BYxoACgkQHPApP6U8
pFhuIhAAwlpK4qoubt2gK9UuX7yV+oMEuRCUtBihMVAQOw+g8DTWk9CIJm5uawIp
yL7lwK1kjwEcYWGyu93y0wWwB4vZKtVosutMVeeepr6dlhPonVcVgoL0ktyelin+
k3PFIh9ieVyU3SxC96ZIYVLYyJu8psZUFpvGthylLL+GWy0uat61cWrU5zMWOb0q
CxEqdpE65VSwZwYCfVz1GiKOnGgJ24y8AHCT1sPrlvY3R/lYkNozIIkD8mp40MYX
9V/3bBAP1VgZG9shlC2pQ2EU2Lu9l6QLdRsL3XgVg2jQEhy3qz3VFmGt84ja/J9x
DbEusx0TTsil1uvSdl5Jj19J7nl3UChZyxZDnMGx8kbMcKQnl8HipCw/lC3pssGt
gqrlse9s6Zq+jHWCBd76PfLNf1owmIkAHVKLtJqiyw16+u4VCCPM5Ev06xdoRFH0
4V+khCe8Cxs+3k1ls5EFuiDpR/8PkRuT0kWQNRR/iXaKvegeWtJLCoij9PjxK0+U
YXx6Axw6PsSJXgay/UVLnjvhbTFmDppCBPLtyXRF3DQiPeUa7X2psPQv5Kfgaxe9
w5bZaDZlollnZ8T6bGTTc/gguBDILSATKOmXIaa+hYDF1pX5sp85qK0iUgW4LBOz
JIn3qVpvcItQ115AN0e7cLapyvuFggVreigEpl4VaCXaOExDryg=
=EOi3
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org