Re: 404 rewrite handler for images

Splash Forums Rewrite Users 404 rewrite handler for images Re: 404 rewrite handler for images

#22569

aaronwalker
Participant

Thanks Christian.

Pretty much what I ended up with some additional filtering based in on the request path.

I’ve been trying to set a EvaluationContext variable in condition and use in the perform step something like

.defineRule()
.when(new HttpCondition() {
@Override
public boolean evaluateHttp(HttpServletRewrite event, EvaluationContext context) {
if (Direction.isInbound().evaluate(event, context)) {
String path = event.getRequestPath();
if(path.contains(".jpg")) {
InputStream stream = event.getRequest().getServletContext().getResourceAsStream(path);
if (stream == null) {
context.put("text",event.getRequestQueryString());
return true;
}
}
}
return false;
}
}
).perform(Redirect.temporary("http://placehold.it/128&text={text}"));

but I get java.lang.IllegalArgumentException: Attempted to access the non-existent EvaluationContext property “{text}”

I’m not sure if I can access this variable in this way

thanks

Aaron