Can i bake a cake in a glass tray, how do i do it?

i want to bake a cake but am not having a metal tray,so can i use a glass tray for it,how do i do it,do i have to apply some oil on it before pouring the mixture