The easiest way to get both in one fell swoop is probably to use the DisplayTag library for creating your HTML table. It offers CSV and XLS downloads without any additional work. Is that what you're asking about?
I have a dynamically generated table (with jstl). When a user clicks a button i want this table to be exported in an excel file... i mean..this table (and only this table from the whole jsp) should be opened in excel.