• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Jsp performance hints and tips
 

Jsp performance hints and tips

on

  • 1,617 views

 

Statistics

Views

Total Views
1,617
Views on SlideShare
1,617
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Jsp performance hints and tips Jsp performance hints and tips Presentation Transcript

    • JSP Performance Hints and Tips Mohan Bang
    • Caching Hints for better performance  Use jspInit() method as cache  Here you are generating both static data and dynamic data from _jspService() method.  Instead what you can do is <%! public void jspInit(){ //create all the static data here // do same for navbar if it's data is static // do same for footer if it's data is static } // end jspInit() method %> out.print(header); out.print(navbar); // write dynamic data here out.print(footer); }
    • Optimization Techniques in Service  Use StringBuffer rather than using + operator when you concatenate multiple strings  Use print() method instead of println() method of out (implicit) object  Use ServletOutputStream instead of JSPWriter  Initialize the out with proper size in the page directive  Flush the data partly  Minimize the amount of code in the synchronized block  Set the content length
    • Optimization Techniques in Page Directive  Page directive defines attributes that apply to an entire JSP page. Here is an example of page directive. <%@ page session="true|false" buffer="none|8kb|size in kb" %>  By default JSP Engine creates session object. If you don't want to use built in HttpSession for a JSP, then make session attribute value as false. It avoids unnecessary creation of session (implicit) object, reduces overhead on memory and garbage collector and increases performance.  By default out (implicit object of JSPWriter) object size is 8kb. You can increase the size if you are sending large data that increases performance. <%@ page session="false" buffer="12kb" %>  here you need to set the size as per page response data if it crosses 8kb.
    • Choosing the right Session Mechanism Session mechanism Performance Description session good There is no limit on size of keeping session data Hidden fields moderate There is no limit on size of passing session data Cookies moderate There is a limit for cookie size URL rewriting moderate There is a limit for URL rewriting Persistent mechanism moderate to poor There is no limit of keeping session data
    • General Hints  Flush the data partly.  Use include directive instead of include action when you want to include the child page content in the translation phase.  Avoid giving unnecessary scope in the 'useBean' action.  Do not use custom tags if you do not have reusability.  Use application server caching facility.  Use Mixed session mechanisms such as 'session' with hidden fields.  Remove 'session' objects explicitly in your program whenever you finish the task.  Reduce session time out value as much as possible.  Use 'transient' variables to reduce serialization overhead if your session tracking mechanism uses serialization process.
    • General Hints  Flush the data partly.  Use include directive instead of include action when you want to include the child page content in the translation phase.  Avoid giving unnecessary scope in the 'useBean' action.  Do not use custom tags if you do not have reusability.  Use application server caching facility.  Use Mixed session mechanisms such as 'session' with hidden fields.  Remove 'session' objects explicitly in your program whenever you finish the task.  Reduce session time out value as much as possible.  Use 'transient' variables to reduce serialization overhead if your session tracking mechanism uses serialization process.