Thursday, April 21, 2005

Reload JSP Tomcat Web Application web.xml File

After a change in a JSP web application's web.xml file to enable filters in the displaytag taglib, I needed to reload the web.xml file to make the changes live. There are a couple of ways to go about this: Restart tomcat or reload the web application or remove then reinstall the web application using the tomcat web manager. I chose to restart tomcat since for my setup I don't have access to the web manager but have easy access to the stop and start .sh scripts. Either way works fine though.

JSP displaytag Excel Filter Error

One of my sites uses the displaytag taglib to format an Oracle result set. I recently tried to add on the export functionality to one of the pages but received this error:

Unable to reset response before returning exported data. You are not using an export filter. Be sure that no other jsp tags are used before display:table or refer to the displaytag documentation on how to configure the export filter (requires j2ee 1.3).

After doing some searching I found that there was not very much info out there but the solution is fairly simple and really is defined by the error message. You need to configure the export filter in your web.xml document. OK, but HOW do you do that? Below are the lines I added to my web.xml file to enable the displaytag export filters.



Then all I had to do was make sure that the JSP web application was reloaded in Tomcat. (See the other post on how to reload the web.xml file). This solution allows you to have JSP tags above your main displaytag table tag. This is very necessary in most applications which do preliminary processing, such as retrieving a dataset, checking login status, etc.