The incident came to light after a student, wanting to speak to him about a timetable change, saw him through a window when a friend lifted him up to look inside the classroom.
Sitting before the judge alone earlier in the month, the court heard how the boy, now aged 17, had liked and respected the teacher prior to the incident.
Afterwards, he was left shocked and "never wanted to speak of it again", a friend said.
The boy gave evidence sitting just metres from the man. He was grilled extensively on the details by defence lawyer Richard Earwaker, who accused him of "making up a story for his mates".
However the judge found the boy was a truthful witness.
Others to give evidence included the school principal, a teacher, a teacher aide, an IT expert and police.
The school's head of IT said a server log showed that the teacher had been accessing Tumblr sites with various URLs.
The man is arguing for permanent name suppression.