Creating Reports with iReports and JasperReports
June 23, 2005
Setting up the Webapp
Now that we have a report to serve and a database set up to populate our report with data, we just need a web component to serve up the report. That component will be a servlet, so we'll also need a web.xml file so Tomcat will know which requests should be handled by the servlet.
The document below is the web.xml file for the sample application. It is fairly straightforward:
- it describes the servlet that will be serving the report; we will visit this servlet in more detail in the next section
- it maps that servlet to handle requests coming to the /ReportEngine path; this could be a regular expression, but we have no need of such complications for this application
- it sets sessions to time out after 30 minutes
- it tells the servlet container to use welcome.html as the default page for this webapp's virtual directory
- it references the jdbc/jasper_example JNDI resource we defined in the previous section
Now that we've got the webapp set up properly, let's see how the servlet is actually performing its task.