04.06.2017 Views

servlets_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Java Servlets<br />

10. SERVLETS – EXCEPTION HANDLING .................................................................................. 46<br />

web.xml Configuration ........................................................................................................................ 46<br />

Request Attributes – Errors/Exceptions ............................................................................................... 47<br />

Error Handler Servlet – Example .......................................................................................................... 48<br />

11. SERVLETS – COOKIES HANDLING ...................................................................................... 52<br />

The Anatomy of a Cookie..................................................................................................................... 52<br />

Servlet Cookies Methods ..................................................................................................................... 53<br />

Setting Cookies with Servlet ................................................................................................................ 54<br />

Reading Cookies with Servlet .............................................................................................................. 56<br />

Delete Cookies with Servlet ................................................................................................................. 58<br />

12. SERVLETS – SESSION TRACKING ....................................................................................... 62<br />

Cookies ................................................................................................................................................ 62<br />

Hidden Form Fields .............................................................................................................................. 62<br />

URL Rewriting ...................................................................................................................................... 62<br />

The HttpSession Object ....................................................................................................................... 63<br />

Session Tracking Example .................................................................................................................... 64<br />

Deleting Session Data .......................................................................................................................... 67<br />

13. SERVLETS – DATABASE ACCESS ........................................................................................ 69<br />

Create Table ........................................................................................................................................ 69<br />

Create Data Records ............................................................................................................................ 70<br />

Accessing a Database........................................................................................................................... 70<br />

14. SERVLETS – FILE UPLOADING ........................................................................................... 74<br />

Creating a File Upload Form ................................................................................................................ 74<br />

Writing Backend Servlet ...................................................................................................................... 75<br />

Compile and Running Servlet ............................................................................................................... 79<br />

iv

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!