Hi.

I have read and pondered your earlier responses, and I am sure that the correct solution is somewhere around the ErrorDocument or the $r->internal_redirect. But I wanted to exhaust the other possibilities first, for the sake of completeness and also to learn more about this all.

So one little bit at a time :

reminder of my config :
<LocationMatch "/servlet.xyz$">
    SetHandler jakarta-servlet
    SetEnvIf REQUEST_URI "\.(htm|web|css|gif|jpg|js|html?)$" no-jk

    AuthType MyModule
    AuthName MyXyzApp
    PerlSetVar MyModule_var1 "value"
    PerlAccessHandler My::Module->some_access_method
    PerlAuthenHandler My::Module->some_auth_method
    PerlAuthzHandler My::Module->some_authz_method
    require valid-user

</Location>

And, in summary, what I was trying to do is :
if the PerlAuthenHandler finds that the request is not authenticated, then it tries to change the response handler for this request, from the original "jakarta-servlet" handler, to my own response handler, which in fact returns a login page. (I need something "active" to return the login page, because I need to insert some data into the login page prior to returning it).

And for that I used this code in the PerlAuthenHandler :

# set our own response handler
$r->handler('modperl');
$r->set_handlers(PerlResponseHandler => \&_send_login_form);
return OK;


One of the possibilities envisioned previously was :

Or, a thought that just occurred to me, is the solution for me
(stopping jakarta-servlet from running and running my
PerlresponseHandler instead), as easy as setting the "no-jk" variable
(if I can do that within my PerlAuthenHandler, and how) ?

I was tempted to suggest that. But I don't know nothing about jakarta. If you want to try use $r->subprocess_env->{'no-jk'}=1;


I tried this, because it was the smallest possible change to my module.
It works, in the sense that it sets the "no-jk" variable, which consequently has the effect of making the "jakarta-servlet" handler above not process this link. But it is not a solution for me, since what happens is that the jakarta-servlet handler is in fact still executed by Apache as the response handler, but it probably just returns DECLINED. Then Apache seems to handle the response with its own default handler, which results in a "404 not found" error.

The other possibility looked at was :
> Or, another thought that just occurred : can I comment out the
> > "SetHandler jakarta-servlet" originally, set my PerlresponseHandler
> > as the default handler in the <Location>, and then *if the user is
> > authenticated* (the contrary of my current condition), *set* the
> > content handler to be jakarta-servlet instead of modperl ?

> Torsten said : Of course.
But Torsten did not say how, and I don't know how to do that.
How can I set the Apache response handler to be "xyz" ? All I have at this point is the name of that handler : "jakarta-servlet". This is not a perl handler, it is mod_jk.so, the Apache/Tomcat AJP connector. (And I do not need code, I just need a pointer in the right direction).

This is now purely for curiosity and for future reference, because after your previous explanations, I am convinced that this is not the right solution for the current problem.

In the meantime, I'll go have a look at $r->internal_redirect, which is probably the correct solution.


Reply via email to