Java Server Pages (JSP) could handle any erros that might be arised in scriptlets, expressions, or other JSP elements. You could use try/cacth blocks to handle any known erros. In this technic we could use to display a custom error on our file where unhandled exception is thrown.
Session are very helpful to associate some data with each visitor. You may pass and retrieve values in diffrent page using sessions. All sessions are an object associated with each web client. In this sample code we will create a session named `username` and later put a value inside our new Session object. On next step we will get our session value. .
Before to start to examine this sample code, you need a SMTP server. If you know your mail server name you could easily use this sample code in a real website. We will use JavaMAIL API. You must put j2ee.jar under WEB-INF/lib folder in your web work folder. Our testing system is Red Hat Linux with Tomcat 5.