That's an EXTREMELY broad question! You could spend weeks studying that...
If you really want an answer, you'll have to ask a much more specific question. I mean, I assume you're using some
J2EE technologies...maybe running on Apache
Tomcat or something like that...there are lots of different methods. You need to provide more details!