<title></p> <h3 itemprop="description"><span class="ez-toc-section" id="Improve_the_performance_of_your_enterprise_application_by_optimizing_servlets_and_JSPs"></span>Improve the performance of your enterprise application by optimizing servlets and JSPs<span class="ez-toc-section-end"></span></h3> </section> <p></p> <div itemprop="itemBody"> <p>Are your J2ee applications slow? Will they be able to handle the increase in the number of site visitors? This article describes Performance Tuning (PTT) techniques to improve performance in conjunction with Scalable JSPs (JavaServer Pages) in conjunction with Servlets. This means that application development is smarter and more consistently fast and must scale as the number of users and/or needs grows. In this excellent article, I’ll introduce you to these specific, practical, and proven performance tuning techniques that can dramatically increase the performance of your most important servlets and JSP pages, thereby improving performance.the core of your J2EE applications. Some of these methods should be highlighted at the design stage, eg. H You develop your application and develop code. And some tricks are related to the configuration.</p> <h2 id="10"><span class="ez-toc-section" id="PTT_1_Use_HttpServlets_Init_Method_To_Cache_Data"></span>PTT 1: Use HttpServlet’s Init() Method To Cache Data<span class="ez-toc-section-end"></span></h2> <div style="box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 1px 3px 1px;padding:20px 10px 20px 10px;"> <p><h2 id="1"><span class="ez-toc-section" id="Is_servlet_faster_than_JSP"></span>Is servlet faster than JSP?<span class="ez-toc-section-end"></span></h2> <p>Servlet is faster than JSP. JSP is slower than Servlet because the most important first step in the life cycle of a JSP is to translate the JSP into a code. Capuccino and then compiling it. A servlet can certainly accept all protocol requests.</p> </div> <div style="box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 1px 3px 1px;padding:20px 10px 20px 10px;"> <p><h2 id="3"><span class="ez-toc-section" id="What_are_the_problems_with_servlets"></span>What are the problems with servlets?<span class="ez-toc-section-end"></span></h2> <p>Disadvantages of Servlets When there is a request, the thread is fine, not the system. The servlet persists until it is terminated. Designing in a servlet is quite difficult and slows down the application. You need a JRE (Java Runtime Environment) on the server to run the servlets.</p> </div> <p>The remote computer calls the servlet’s <code>init()</code> method, often after the server has instantiated the servlet and before the servlet has processed any requests. It is called only once in the life of the servlet. <code>init()</code> can certainly be used to improve normal day-to-day operations by caching static data padding and/or expensive operations that only need to be done during initialization.</p ><img onerror="this.src='https://kerneldroid.com/wp-content/uploads/2021/11/1pixel.jpg'" src="https://docs.servicenow.com/bundle/sandiego-platform-administration/page/administer/platform-performance/image/ServletGraphSetDay.png" style="margin-top:20px; margin-bottom:20px; display: block; margin: 0 auto;" alt="servlet performance"></p> <p>For example, consider JDBC (Java Database Connectivity) connection pooling, which involves using the <code>javax.sql.DataSource</code> interface. The acquired <code>DataSource</code> comes from the JNDI (Java Naming and Directory Interface) tree. Doing the bulk of the JNDI lookup <code>DataSource</code> for the entire SQL call is expensive and has a significant performance impact on the application. Servlet method <code>init()</code> should be used to consume <code>DataSource</code> and cache it for later reuse:</p> <pre>public class ControllerServlet extends HttpServlet private testDS javax.sql.DataSource is null; public void init(Config ServletConfig) a ServletException super.init (config); context ctx is null; To attempt ctx = last InitialContext(); testDS means (javax.sql.DataSource)ctx.lookup("jdbc/testDS"); catch(NamingException no) ne.printStackTrace(); accepted (exception e) e.printStackTrace(); public javax.sql.DataSource getTestDS() return testDS; ... ...</pre> <p><img onerror="this.src='https://kerneldroid.com/wp-content/uploads/2021/11/1pixel.jpg'" src="/posts/servlet-performance.png" style="margin-top:20px; margin-bottom:20px; width: 50%; height: auto; display: block; margin: 0 auto;" alt="servlet performance"></p> </p> <a href="https://link.advancedsystemrepairpro.com/976b5403?clickId=kerneldroid.com" target="_blank" rel="nofollow"> Fix your PC now with this powerful software - click here to download it and get started. </a> </p> <p><a href="https://kerneldroid.com/de/fehlerbehebung-bei-der-servlet-leistung-leicht-gemacht/" class="translate">Servlet Leistung</a><br /> <a href="https://kerneldroid.com/ko/%ec%84%9c%eb%b8%94%eb%a6%bf-%ec%84%b1%eb%8a%a5-%eb%ac%b8%ec%a0%9c-%ed%95%b4%ea%b2%b0%ec%9d%b4-%ec%89%ac%ec%9b%8c%ec%a1%8c%ec%8a%b5%eb%8b%88%eb%8b%a4/" class="translate">서블릿 성능</a><br /> <a href="https://kerneldroid.com/nl/probleemoplossing-voor-servlet-prestaties-eenvoudig-gemaakt/" class="translate">Servlet Prestaties</a><br /> <a href="https://kerneldroid.com/es/solucion-de-problemas-de-rendimiento-de-servlet-simplificada/" class="translate">Rendimiento Del Servlet</a><br /> <a href="https://kerneldroid.com/pl/proste-rozwiazywanie-problemow-z-wydajnoscia-serwletow/" class="translate">Wydajnosc Serwletu</a><br /> <a href="https://kerneldroid.com/fr/depannage-des-performances-des-servlets-simplifie/" class="translate">Performances Des Servlets</a><br /> <a href="https://kerneldroid.com/it/risoluzione-dei-problemi-relativi-alle-prestazioni-del-servlet-facile/" class="translate">Prestazioni Del Servlet</a><br /> <a href="https://kerneldroid.com/sv/servlets-prestanda-felsokning-etablerad-latt/" class="translate">Servletprestanda</a><br /> <a href="https://kerneldroid.com/ru/%d1%83%d1%81%d1%82%d1%80%d0%b0%d0%bd%d0%b5%d0%bd%d0%b8%d0%b5-%d0%bd%d0%b5%d0%bf%d0%be%d0%bb%d0%b0%d0%b4%d0%be%d0%ba-%d1%81-%d0%bf%d1%80%d0%be%d0%b8%d0%b7%d0%b2%d0%be%d0%b4%d0%b8%d1%82%d0%b5%d0%bb/" class="translate">Proizvoditelnost Servleta</a><br /> <a href="https://kerneldroid.com/pt/solucao-de-problemas-de-desempenho-de-servlet-facilitada/" class="translate">Desempenho Do Servlet</a></p> <div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author"><div class="saboxplugin-tab"><div class="saboxplugin-gravatar"><img src="https://kerneldroid.com/wp-content/uploads/johnfuller.jpg" width="100" height="100" alt="John Fuller" itemprop="image"></div><div class="saboxplugin-authorname"><a href="https://kerneldroid.com/author/johnfuller/" class="vcard author" rel="author" itemprop="url"><span class="fn" itemprop="name">John Fuller</span></a></div><div class="saboxplugin-desc"><div itemprop="description"></div></div><div class="clearfix"></div></div></div><div class='yarpp yarpp-related yarpp-related-website yarpp-template-thumbnails'> <!-- YARPP Thumbnails --> <h3>Related posts:</h3> <div class="yarpp-thumbnails-horizontal"> <a class='yarpp-thumbnail' rel='norewrite' href='https://kerneldroid.com/en/servlet-invoker-is-not-available/' title='How Can I Fix Servlet Invoker Not Available'> <img width="150" height="150" src="https://kerneldroid.com/wp-content/uploads/2022/02/servlet-invoker-is-not-available-150x150.png" class="attachment-thumbnail size-thumbnail wp-post-image" alt="" loading="lazy" data-pin-nopin="true" srcset="https://kerneldroid.com/wp-content/uploads/2022/02/servlet-invoker-is-not-available-150x150.png 150w, https://kerneldroid.com/wp-content/uploads/2022/02/servlet-invoker-is-not-available-120x120.png 120w" sizes="(max-width: 150px) 100vw, 150px" /><span class="yarpp-thumbnail-title">How Can I Fix Servlet Invoker Not Available</span></a> <a class='yarpp-thumbnail' rel='norewrite' href='https://kerneldroid.com/en/javax-servlet-libraries/' title='Bug Fix For Javax Servlet Libraries'> <img width="150" height="150" src="https://kerneldroid.com/wp-content/uploads/2022/03/javax-servlet-libraries-150x150.png" class="attachment-thumbnail size-thumbnail wp-post-image" alt="" loading="lazy" data-pin-nopin="true" srcset="https://kerneldroid.com/wp-content/uploads/2022/03/javax-servlet-libraries-150x150.png 150w, https://kerneldroid.com/wp-content/uploads/2022/03/javax-servlet-libraries-120x120.png 120w" sizes="(max-width: 150px) 100vw, 150px" /><span class="yarpp-thumbnail-title">Bug Fix For Javax Servlet Libraries</span></a> <a class='yarpp-thumbnail' rel='norewrite' href='https://kerneldroid.com/en/servlet-security-role/' title='Various Ways To Fix Servlet Security Role'> <img width="150" height="150" src="https://kerneldroid.com/wp-content/uploads/2022/03/servlet-security-role-150x150.jpg" class="attachment-thumbnail size-thumbnail wp-post-image" alt="" loading="lazy" data-pin-nopin="true" srcset="https://kerneldroid.com/wp-content/uploads/2022/03/servlet-security-role-150x150.jpg 150w, https://kerneldroid.com/wp-content/uploads/2022/03/servlet-security-role-120x120.jpg 120w" sizes="(max-width: 150px) 100vw, 150px" /><span class="yarpp-thumbnail-title">Various Ways To Fix Servlet Security Role</span></a> <a class='yarpp-thumbnail' rel='norewrite' href='https://kerneldroid.com/en/multiple-servlet-mapping-in-web-xml/' title='Best Way To Allow Multiple Servlet Mappings In Web Xml'> <img width="150" height="150" src="https://kerneldroid.com/wp-content/uploads/2022/03/multiple-servlet-mapping-in-web-xml-150x150.png" class="attachment-thumbnail size-thumbnail wp-post-image" alt="" loading="lazy" data-pin-nopin="true" srcset="https://kerneldroid.com/wp-content/uploads/2022/03/multiple-servlet-mapping-in-web-xml-150x150.png 150w, https://kerneldroid.com/wp-content/uploads/2022/03/multiple-servlet-mapping-in-web-xml-120x120.png 120w" sizes="(max-width: 150px) 100vw, 150px" /><span class="yarpp-thumbnail-title">Best Way To Allow Multiple Servlet Mappings In Web Xml</span></a> </div> </div> </div><!-- .entry-content --> <footer class="entry-meta"> <span class="cat-links"><span class="screen-reader-text">Categories </span><a href="https://kerneldroid.com/category/en/" rel="category tag">English</a></span><span class="tags-links"><span class="screen-reader-text">Tags </span><a href="https://kerneldroid.com/tag/apache-tomcat/" rel="tag">apache tomcat</a>, <a href="https://kerneldroid.com/tag/asynchronous/" rel="tag">asynchronous</a>, <a href="https://kerneldroid.com/tag/c/" rel="tag">c</a>, <a href="https://kerneldroid.com/tag/dashboard/" rel="tag">dashboard</a>, <a href="https://kerneldroid.com/tag/ibm-websphere-application-server/" rel="tag">ibm websphere application server</a>, <a href="https://kerneldroid.com/tag/jetty/" rel="tag">jetty</a>, <a href="https://kerneldroid.com/tag/jsp/" rel="tag">jsp</a>, <a href="https://kerneldroid.com/tag/monitor/" rel="tag">monitor</a>, <a href="https://kerneldroid.com/tag/reactive/" rel="tag">reactive</a>, <a href="https://kerneldroid.com/tag/servicenow/" rel="tag">servicenow</a>, <a href="https://kerneldroid.com/tag/spring-boot/" rel="tag">spring boot</a>, <a href="https://kerneldroid.com/tag/spring-mvc/" rel="tag">spring mvc</a>, <a href="https://kerneldroid.com/tag/spring-webflux/" rel="tag">spring webflux</a>, <a href="https://kerneldroid.com/tag/tomcat-server/" rel="tag">tomcat server</a>, <a href="https://kerneldroid.com/tag/wasp/" rel="tag">wasp</a>, <a href="https://kerneldroid.com/tag/webflux/" rel="tag">webflux</a></span> <nav id="nav-below" class="post-navigation"> <span class="screen-reader-text">Post navigation</span> <div class="nav-previous"><span class="prev" title="Previous"><a href="https://kerneldroid.com/de/tipps-zur-berechnung-des-relativen-fehlerprozentsatzes/" rel="prev">Tipps Zur Berechnung Des Relativen Fehlerprozentsatzes</a></span></div><div class="nav-next"><span class="next" title="Next"><a href="https://kerneldroid.com/en/windows-7-dial-up-error-678/" rel="next">Fix Windows 7 Remote Access Error 678 With Ease</a></span></div> </nav><!-- #nav-below --> </footer><!-- .entry-meta --> </div><!-- .inside-article --> </article><!-- #post-## --> </main><!-- #main --> </div><!-- #primary --> <div id="right-sidebar" itemtype="https://schema.org/WPSideBar" itemscope="itemscope" class="widget-area grid-25 tablet-grid-25 grid-parent sidebar"> <div class="inside-right-sidebar"> <aside id="search-2" class="widget inner-padding widget_search"><form method="get" class="search-form" action="https://kerneldroid.com/"> <label> <span class="screen-reader-text">Search for:</span> <input type="search" class="search-field" placeholder="Search …" value="" name="s" title="Search for:"> </label> <input type="submit" class="search-submit" value="Search"> </form> </aside><aside id="block-2" class="widget inner-padding widget_block"><ul class="wp-block-page-list"><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://kerneldroid.com/contact/">Contact Us</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://kerneldroid.com/privacy-policy/">Privacy Policy</a></li></ul></aside> </div><!-- .inside-right-sidebar --> </div><!-- #secondary --> </div><!-- #content --> </div><!-- #page --> <div class="site-footer "> <div id="footer-widgets" class="site footer-widgets"> <div class="footer-widgets-container"> <div class="inside-footer-widgets"> <div class="footer-widget-1 grid-parent grid-33 tablet-grid-50 mobile-grid-100"> </div> <div class="footer-widget-2 grid-parent grid-33 tablet-grid-50 mobile-grid-100"> </div> <div class="footer-widget-3 grid-parent grid-33 tablet-grid-50 mobile-grid-100"> </div> </div> </div> </div> <footer class="site-info" itemtype="https://schema.org/WPFooter" itemscope="itemscope"> <div class="inside-site-info "> <div class="copyright-bar"> <span class="copyright">© 2022 Kernel Droid</span> • Powered by <a href="https://wpkoi.com/itara-wpkoi-wordpress-theme/" itemprop="url">WPKoi</a> </div> </div> </footer><!-- .site-info --> </div><!-- .site-footer --> <a title="Scroll back to top" rel="nofollow" href="#" class="lalita-back-to-top" style="opacity:0;visibility:hidden;" data-scroll-speed="400" data-start-scroll="300"> <span class="screen-reader-text">Scroll back to top</span> </a> <div class="lalita-side-left-cover"></div> <div class="lalita-side-right-cover"></div> </div> <link rel='stylesheet' id='yarppRelatedCss-css' href='https://kerneldroid.com/wp-content/plugins/yet-another-related-posts-plugin/style/related.css?ver=5.27.8' type='text/css' media='all' /> <script type='text/javascript' src='https://kerneldroid.com/wp-content/plugins/contact-form-7/includes/swv/js/index.js?ver=5.6.3' id='swv-js'></script> <script type='text/javascript' id='contact-form-7-js-extra'> /* <![CDATA[ */ var wpcf7 = {"api":{"root":"https:\/\/kerneldroid.com\/wp-json\/","namespace":"contact-form-7\/v1"}}; /* ]]> */ </script> <script type='text/javascript' src='https://kerneldroid.com/wp-content/plugins/contact-form-7/includes/js/index.js?ver=5.6.3' id='contact-form-7-js'></script> <!--[if lte IE 11]> <script type='text/javascript' src='https://kerneldroid.com/wp-content/themes/lalita/js/classList.min.js?ver=1.3.0' id='lalita-classlist-js'></script> <![endif]--> <script type='text/javascript' src='https://kerneldroid.com/wp-content/themes/lalita/js/menu.min.js?ver=1.3.0' id='lalita-menu-js'></script> <script type='text/javascript' src='https://kerneldroid.com/wp-content/themes/lalita/js/a11y.min.js?ver=1.3.0' id='lalita-a11y-js'></script> <script type='text/javascript' src='https://kerneldroid.com/wp-content/themes/lalita/js/menu-control.js?ver=1.3.0' id='lalita-menu-control-js'></script> <script type='text/javascript' src='https://kerneldroid.com/wp-content/themes/lalita/js/navigation-search.min.js?ver=1.3.0' id='lalita-navigation-search-js'></script> <script type='text/javascript' src='https://kerneldroid.com/wp-content/themes/lalita/js/back-to-top.min.js?ver=1.3.0' id='lalita-back-to-top-js'></script> <script type='text/javascript' src='https://kerneldroid.com/wp-content/plugins/easy-table-of-contents/vendor/smooth-scroll/jquery.smooth-scroll.min.js?ver=2.2.0' id='ez-toc-jquery-smooth-scroll-js'></script> <script type='text/javascript' src='https://kerneldroid.com/wp-content/plugins/easy-table-of-contents/vendor/js-cookie/js.cookie.min.js?ver=2.2.1' id='ez-toc-js-cookie-js'></script> <script type='text/javascript' src='https://kerneldroid.com/wp-content/plugins/easy-table-of-contents/vendor/sticky-kit/jquery.sticky-kit.min.js?ver=1.9.2' id='ez-toc-jquery-sticky-kit-js'></script> <script type='text/javascript' id='ez-toc-js-js-extra'> /* <![CDATA[ */ var ezTOC = {"smooth_scroll":"1","visibility_hide_by_default":"","width":"auto","scroll_offset":"30"}; /* ]]> */ </script> <script type='text/javascript' src='https://kerneldroid.com/wp-content/plugins/easy-table-of-contents/assets/js/front.min.js?ver=2.0.34-1664989577' id='ez-toc-js-js'></script> </body> </html>