A teacher has been jailed after stabbing a school principal upon learning his contract wouldn't be renewed.