Sambhashanam
तकनीकी संभाषणम्
Navigation
  • Microsoft Technologies
  • Java Technologies
  • LAMP Technologies
  • Opensource
    • Microsoft Opensource
    • LAMP Opensource
    • Java Opensource
You are here: Home › Java Opensource › Struts2 – Performance Tuning
← Solving JBoss 5 classloading issues in JBPM 5.1.0 in a web application
Configure WebLogic Server 10.3.1 to print the SOAP request and response messages for each web service invocation →

Struts2 – Performance Tuning

December 7, 2011 | Filed under: Java Opensource, Java Technologies, Opensource, Random Java, JEE Tips & Tricks & News and tagged with: Jee, struts 2, struts 2 performance

I was involved in migration of a very web application recently. The main reason for migration was cited as performance. Finally we have choosen Struts 2 (Struts 2.2.1.1 to be exact) for this migration. I have done some POC and found that performance was good.

Days passed by and we ended up with a application that contained thousands of JSP. When I tested the application for performance and I was shocked! The response was slow beyond the imagination. I started looking for performance tips on the net (google actually) and landed on this Official Struts 2 Performance Tuning Link. Applied the required changes based on the document but result was still shocking.

Further delved into XML files available in struts 2 jar’s and came up with following solutions and performance was much better than the imagination. And yes this was a sigh of relief for me. Try it out this will surely improve performance of any struts 2 based applications.

 S.No Changes Needs to be Done Struts 2 File / JAR To be modified Benefits
1  <constant
name="struts.devMode"
value="false" />
struts.xml  If devMode is set to true, it allows
reloading of configuration and validation
related files, but because they happen on
each request ,this setting will totally kill
your performance.So, Turn off the devMode to
increase performance.
2 <constant
name="struts.freemarker.templatesCache"
value="true"/> 

struts.xml

 struts2-core-2.2.1.1.jar

 struts2-dojo-plugin-2.2.1.1.jar

 It enable the struts internal caching of
Freemarker templates.
Just adding this property will not change anything. 
You have to modify the struts2-core-2.2.1.1.jar and
struts2-dojo-plugin-2.2.1.1.jar by moving out
the template folder respectively and add this folder to
root of the web application (parallel to WEB-INF). The
built in Freemarker caching mechanism fails to cache
templates when they are retreived from class path(or
jars) and decrease the performance
3 <constant name="struts.xslt.nocache"
value="false"/> 
struts.xml This property configures the XSLTResult class to
use stylesheet caching. Set this property to true for
developers and false for productions.
4 <constant
name="struts.ognl.logMissingProperties" 
value="=false"/>
struts.xml Logs as warning properties that are not found
5 <constant
name="struts.el.throwExceptionOnFailure"
value="false"/>
struts.xml This property instructs struts 2 runtime
whether to throw a runtime exception when a property is
not found in an expression  or when the expression
evaluates to fails
6 <constant
name="struts.ognl.enableExpressionCache" 
value="true"/>
struts.xml Caches parsed OGNL expression. If your application
generates a lot of OGNL expressions,this property saves
a lot.
7 <constant name="struts.serve.static"
value="false"/>
struts.xml FilterDispatcher uses this attribute. If true then
Struts serves static content from inside the jars and if
false struts serves static content from the
/<WEBAPP_ROOT_DIR>/struts. To achieve this
move the static folder content from
struts2-dojo-plugin-2.2.1.1.jar(when using Ajax
theme(DOJO) or Calender tag )  and core-2.2.1.1.jar
to /<WEBAPP_ROOT_DIR>/struts.
8 Add a freemarker.properties file in WEB-INF/classes folder and add the
following:.



tempate_update_delay=600000000

WEB-INF/classes/freemarker.properties This value determine s how often Freemarker checks if it
needs to reload the template from disk.In production
this feature is not needed, thus set it to larger value
for better performance
9 Use ${attribute} rather <s:property
value=’#attribute’ />
JSP  
10 Use "<s:property value="{getText(‘A_KEY’)}"/>
rather than <s:i18n name="messageresource.package">


<s:text name="A_KEY"/>


</s:i18n>"

JSP  

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Google+ (Opens in new window)

Related

Did you like this article? Share it with your friends!

Tweet

Written by Dhananjay Jha

I am a java professional working with a software firm in Noida as "Manager - Product Engineering". I am always keen to learn and share what I have learnt. More professional details about me are available at Linked In and social details are available at facebook and Google Plus. I share my thought in maithili (my mother tongue) at बताह मैथिल and bataahmaithil

Follow me on Twitter
← Solving JBoss 5 classloading issues in JBPM 5.1.0 in a web application
Configure WebLogic Server 10.3.1 to print the SOAP request and response messages for each web service invocation →

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Authors

  • Dhananjay Jha
  • Manish Kumar
  • Sushil Pandey

Recent Comments

  • muhammad on Mail merge in java for Microsoft Word document – Part I
  • muhammad on Mail merge in java for Microsoft Word document – Part I
  • Dhananjay Jha on Mail merge in java for Microsoft Word document and convert to PDF without iText – Part II
  • Clyde Symonette on Mail merge in java for Microsoft Word document and convert to PDF without iText – Part II
  • Dhananjay Kumar Jha on Mail merge in java for Microsoft Word document and convert to PDF without iText – Part II

Tag Cloud

.net activiti activiti-spring activiti bpmn C# change sender mail id in wordpress class classloader Conver MS Word to PDF disable user wordpress dox4j glassfish http response compression java Java Mail Merge MS Word javascript confirmation link on image jax-ws on tomcat jax-ws webservice Jee JTS junit junit-spring Link on Image with hidden URL link load spring configuration load spring configuration xml junit maven maven build Merge MS Word using Java Merge Word Document using XdocReport OOPS oracle weblogic PDF conversion using docx4j php mail function sample activiti process with human task and service task sending mail with attachment spring-orm spring framework spring hibernate spring hibernate integration spring jpa spring jpa hibernate integration tomcat jax-ws web service wordpress wordpress sender email

Looking for old post?

© 2021 Sambhashanam