Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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
add comment

2 Answers 2

up vote 8 down vote accepted

This might be better done through security groups.

Pseudo code:

if(user.InGroup("TestAccounts")).....
share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.