tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith Ealanta <keith.eala...@editure.com>
Subject Re: JkSetEnv and Servlet Filters
Date Sun, 04 May 2008 13:10:48 GMT
Rainer Jung wrote:
> Hi Keith,
>
> Keith Ealanta schrieb:
>> Can anyone advise me how to access the attributes set in an http 
>> request using JkSetEnv?
>
> I just tried it again, it works for me.
>
>> Specifically I'm using JkSetEnv on Apache2.0 to set a number of 
>> attributes in the request.
>> I have captured the mod_jk packets (on port 8009) and they contain 
>> the items I've set in the attributes section as req_attribute type 
>> (code 0x0A)
>> When I access the ServletRequest object I cannot find this data 
>> anywhere. I've downloaded a number of ServletRequest display filters 
>> and none of them show the data either.
>
> I simply retrieve any attribute via
>   request.getAttribute(nameOfTheAttribute)
> from the ServletRequest.
>
>> Are these attributes only useful for setting specific values the 
>> system understands, is there some other way for me to access these 
>> values from the ServletRequest object in Tomcat, or alternately is it 
>> possible there is some error in mod_jk or Tomcat such that the data 
>> is never extracted (if it even should be).
>
> It works for me. Which versions of mod_jk and Tomcat are you using?
Mod_jk: 1:1.2.18-3
Apache2: Apache/2.0.54

/opt/tomcat/bin/version.sh
Server version: Apache Tomcat/5.5.17
Server built:   Apr 14 2006 02:08:29
Server number:  5.5.17.0
OS Name:        Linux
OS Version:     2.6.18-4-xen-vserver-amd64
Architecture:   i386
JVM Version:    1.6.0_03-b05
JVM Vendor:     Sun Microsystems Inc.

> How does your JK config look like (yes, I know you already wrote you 
> can see the attribute set in the debug log, but let's make sure)?
Extract from file /etc/apache2/conf.d/player.conf
# JK
JkEnvVar AUTH_TYPE "<UNSET>"
JkEnvVar REMOTE_USER "<UNSET>"
JkEnvVar SINA_CUSTOMER "<UNSET>"
JkEnvVar SINA_EA "<UNSET>"
JkEnvVar SINA_USER_GROUP_NAME "<UNSET>"
JkWorkersFile   /etc/libapache2-mod-jk/workers.properties.mycms-scorm
JkLogFile       /var/log/apache2/mod_jk.log
JkLogLevel      info
JkMount /my_player* icodeon

# this is a hack to redirect this

<Location /my_player>
        AuthName SINA
        AuthType Basic
        Auth_SINAuser on
        Auth_SINAextras off
        Auth_SINAexpire on
        Auth_SINAproxys 1.1.1.1/255.255.255.255
        ErrorDocument 401 /utils/auth/admin/
        ErrorDocument 503 /utils/error/resolver/
        SINA_Load_Max 100
        ErrorDocument 416 /utils/load/admin/
JkMount icodeon
        <Limit GET POST PUT>
                order deny,allow
                allow from all
                require valid-user
        </Limit>
</Location>




file: /etc/libapache2-mod-jk/workers.properties.mycms-scorm
# Define some properties
  workers.apache_log=/var/log/tomcat
#  worker.list=scorm,olat,icodeon
  worker.list=icodeon
  ps=/

# Set properties for worker1 (ajp13)
  worker.icodeon.type=ajp13
# FIXME use host name "scorm"?
# worker.icodeon.host=scorm
  worker.icodeon.host=debian
  worker.icodeon.port=8009
  worker.icodeon.connection_pool_size=10
  worker.icodeon.connection_pool_timeout=600
  worker.icodeon.socket_keepalive=1
  worker.icodeon.socket_timeout=60
#  worker.icodeon.mount=/my_player*

>
> There have been no changes to that code recently. I'm using TC 5.5.26 
> in my test.
>
Hmm, I'm guessing I may need to find more recent versions (probably 
back-ports)
>> I'm guessing I'm just looking for it in all the wrong places, so I'm 
>> hoping someone can point me in the right direction.
>
> How do you retrieve the env var on the Tomcat side?
public void doFilter(ServletRequest servletRequest, ServletResponse 
servletResponse, FilterChain filterChain) throws IOException, 
ServletException {
        log.debug("\nAttributes ... begin.\n");
        Enumeration attributeNames = servletRequest.getAttributeNames();
        while(attributeNames.hasMoreElements()) {
          String attributeName = (String) attributeNames.nextElement();
          log.debug(attributeName + " " + 
servletRequest.getAttribute(attributeName));
        }
        log.debug("\nAttributes ... end.\n");
etc.
}

Thanks for looking at this.
I'm now suspecting I need a more recent version of Tomcat.
Just in case though, your test code was run as a filter?  I've been 
wondering if the filter saw something different from what the servlet sees?

Regards,
Keith


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message