Spring Web MVC - Spring Web Flow Working With JasperReports

Step 1: Creating the structure folders

To do this tutorial quickly and easily, create a Tomcat project called springjasperreports in the webapps folder of your Tomcat installation. I will show you a structure of all folders inside the project (would change according your logic). At first glance it can be a little confusing but later it will be easier to understand.

 

Step 2: Configuring web.xml


<display-name>springjasperreports</display-name>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>springjasperreports.root</param-value>
</context-param>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/springjasperreports-servlet.xml
/WEB-INF/xml/context/applicationContext-swf.xml
/WEB-INF/xml/context/applicationContext-jasperreports.xml
/WEB-INF/xml/context/applicationContext-jasperreportsengine.xml
</param-value>
</context-param>

<servlet>
<servlet-name>springjasperreports</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>detectAllViewResolvers</param-name>
<param-value>false</param-value>
</init-param>
</servlet>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet-mapping>
<servlet-name>springjasperreports</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<taglib>
<taglib-uri>/spring</taglib-uri>
<taglib-location>/WEB-INF/spring.tld</taglib-location>
</taglib>

An important part would be contextConfigLocation, there you can see

  • /WEB-INF/springjasperreports-servlet.xml (for view resolver,url mapping, and some Web MVC beans)
  • /WEB-INF/xml/context/applicationContext-swf.xml (for flow configuration)
  • /WEB-INF/xml/context/applicationContext-jasperreports.xml (for a controller to handle a request )
  • /WEB-INF/xml/context/applicationContext-jasperreportsengine.xml (for our report engine)

 

Article Type: 
How-to
0
Average: 4 (1 vote)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

clermont38 replied on Fri, 2009/05/15 - 12:18pm

Is there source code for this?

cnbaluramesh replied on Sat, 2009/06/13 - 4:03am

Very interesting article. Where is the code ?

vijayasaradhi_p replied on Tue, 2009/08/18 - 10:56pm

This is very good article.. where can I get the Source code?

rajesh_dzone replied on Sun, 2009/09/27 - 9:47pm

The article is gud ..can i get the source code

zizul replied on Fri, 2009/11/13 - 5:24am

Helpful article, any chances to get a source code ?

Manuel Jordan replied on Sat, 2009/11/14 - 10:23pm

Hello Guys

 

The source is almost available.

My hard disk crushed months ago, and the source code is somewhere among many DVD,

Regards

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.