In my JSP web application, I want to redirect sample users to a different page from the real users.

Currently we do something like

if((user.getName().equalsIgnoreCase("Sample")) ...

This is (a) hardcoded and (b) executed for each normal user as well.

Is there a better way to handle this logic?

I am loathe to redirect these users via Javascript validation - which is one of the suggestions given internally

2 Answers 2


This might be better done through security groups.

Pseudo code:


I don't see a problem redirecting sample users like that. We are using this technic too so that we could use functional tests.

Another solution is writing a filter which you can then switch off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.