The 10th student says white if she sees an even number of white hats and red if she sees an odd number of white hats (she will be the only one that could make a mistake). The 9th student now sees 8 hats in front of her. Say X of them are white. Now there are four possibilities:

- 10th student said white and X is even: She wears a red hat
- 10th student said white and X is odd: She wears a white hat
- 10th student said red and X is even: She wears a white hat
- 10th student said red and X is odd: She wears a red hat

You can also use this solution which is based on 'compression'

They decide to talk one after the other starting from the back. The one at the back (student 10) looks at the next one (student 9) and speaks out the color. Since one student is allowed to make a mistake, it's ok if it's wrong. Next one (student 9) repeats the color immediately if it's the same as next one's hat color, or waits for a couple of seconds and speaks out the color. So, the next one (student 8) will know if he is wearing the same color or different and he and the rest will follow the same rule until the first row student...

Note that, if the colors are mostly same, students will speak out quickly. But if they are mostly mixed, it will take longer to reveal the colors. (An interesting idea for those who are familiar with data compression)