In general, a JSP should only be used for displaying somethign to the user. Servlets should be used for calculation code that does not display anything to the user.
The reason for this is two-fold: a). They are designed that way (do it because we said so!
) and b). You have more direct control over things with a servlet.
A little elaboration on b). If you want to redirect the user to another page, you cannot write anything to the output stream before redirecting, else you will get a runtime error. JSPs, however, are designed to write things to the output stream. This doesn't mean that you can't use JSPs to do the job, it just means that you have to be very careful with how you code them, else you will get this error.
Remember that when it comes to Web Apps, JSPs are compiled into servlets behind the scenes. This means that Servlets are required for a web app; JSPs are not.
(Also, the Web Server has to compile a JSP the first time you use it. By writing non-user-output code into servlets, you save just that tiny bit of overhead...)
So the
pattern is something like this:
User Form (JSP) -> Process Form (Servlet; data processing happens here) -> Results page (JSP, redirected to from the Servlet)
Hope this helps