A stepper motor's shaft has permanet magnets attached to it. Around the body of the motor is a series of coils that create a magnetic field that interacts with the permanet magnets. When these coils are turned on and off the magnetic field causes the rotor to move. As the coils are turned on and off in sequence the motor will rotate forward or reverse. At any given time the computer will know the position of the motor since the number of steps given can be tracked. This is true only if some outside force of greater strength than the motor has not interfered with the motion.
This type of motors are controlled with:
Given a varying load, there is no way to tell the velocity/position of the motor, apart using an encoder or measuring the back emf.
The most common types of encoders are:
A servo motor is, usually, a box with built in DC motor, gearbox, position feedback mechanism and controlling electronics. The servo motor can be controlled to move any position just by using simple pulse controlling.