Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 8 down vote accepted

This might be better done through security groups.

Pseudo code:

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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