Hi,
It's fairly pointless to rely on getServerInfo and similar approaches: it's one
of the first things security-conscious server administrators customize or
spoof, as that's a recommended best practice.

Class-name-based detections (e.g. Class.forName("org.apache.catalina.foo.bar")
for Tomcat) are also risky at best, as for example JBoss bundles Tomcat,
numerous other containers bundle Jasper, etc.  But it's better than using
getServerInfo.

All of this should be done really as a last resort -- the servlet classes in
log4j should be (and I think are, so I'm wondering where you see a need)
designed to the Servlet Specification...

Yoav

--- Andy McBride <[EMAIL PROTECTED]> wrote:

>   
> >
> >Also, does anyone know if there is a way to 
> >programmatically detect the web
> >container the web app is running under?  I am seeing a 
> >need to have
> >different behavior between JBoss and Tomcat, and I was 
> >just wondering if
> >there is a standard way to detect this.
> >
> >-Mark
> >
> 
> Mark, 
> 
> The ServletContext has a getServerInfo() method which 
> according the javadoc: 
> 
> Returns the name and version of the servlet container on 
> which the servlet is running. 
> The form of the returned string is 
> servername/versionnumber. For example, the JavaServer Web 
> Development Kit may return the string JavaServer Web Dev 
> Kit/1.0. 
> The servlet container may return other optional 
> information after the primary string in parentheses, for 
> example, JavaServer Web Dev Kit/1.0 (JDK 1.1.6; Windows NT 
> 4.0 x86)
> 
> 
> So the output "should" be easy to parse but I wouldn't 
> like to put money on every server vendor complying with 
> this contract!
> 
> I must admit I'm curious to know what need you forsee to 
> have to accomodate different behaviour depending on 
> container vendor?  The main point of the J2EE spec is to 
> provide a vendor-neutral API for applications to code to. 
>  
> The cost of maintaining specific behaviour dependant on 
> server vendor would be huge with the current abundance of 
> server vendors.  
> 
> Cheers
> 
> Andy
> The information contained in this e-mail is intended only for the person or
> entity to which it is addressed and may contain confidential and/or
> privileged material.  If You are not the intended recipient of this e-mail,
> the use of this information or any disclosure, copying or distribution is
> Prohibited and may be unlawful.  If you received this in error, please
> contact the sender and delete the material from any computer.  The views
> expressed in this e-mail may not necessarily be the views of The PCMS Group
> plc and should not be taken as authority to carry out any instruction
> contained.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to