I have noticed that it takes a long time for the pages in my app to load the first time. The action class executes quickly and it takes at least 6 to 10 seconds to render the page after that. I am using struts and jstl tags (struts 1.2.9) and no custom tags.
My application uses tiles. And each tile in a jsp imports struts/jstl tag libraries. Each jsp page has about 4 to 5 tiles. I understand that the first time the page is called, it is compiled. But isn't 10 seconds long for displaying a page?
Is it the taglib imports in each tile that is slowing down the process? Is there anyway i could import the taglibs only once instead of calling them for each tile in the layout?
I've done few R&D in this and finally i came to conclusion that these problems are due to JSP's.
While you Build the Application the JSP's will generate class files for all the JSP's. Check the EAR/WAR file for the Class files of all the JSP's and then Deploy the application.
The Reason : After the Application is deployed in Prod/Pilot Server when you try to click on some JSP, the Jsp will actually try to create a class file for the same and because of that it takes time to load. so instead you create the Class files even before Deploying the EAR/WAR file in Server.
Steps in RAD to create the Class Files in JSP: 1. Right the Web Project under the Dynamic Projects for "Properties", here there is a option called "JSP Compilation". By Default the "when Server Displays page" options will be chosen, Change the option to "when project is built in workspace" and chek the checkbox. This will lead you to create the Class files of JSP's.
The original post doesn't contain enough information to conclude that the problem is due to JSPs. It could just as well be that the application logic or database access is taking a while. The first step in diagnosing this would be to determine what is taking up how much time. Then one can start addressing it. [ March 11, 2008: Message edited by: Ulf Dittmer ]
A 10 second lag sounds about right for the time required to translate your JSP into Java code and then compile the generated Java code. Most application servers have a way to precompile your JSP files so that user's do not see this delay.
Joined: Jan 24, 2008
RAD - IBM Rational Application Developer, its an IDE for developing Applications. IBM Rational Application Developer (RAD) is the new generation of Java application development environments built on the Eclipse open platform.
The Steps which i gave is to do the Pre-Compilation of JSPs in RAD IDE. For More info: Info on RAD
what is the IDE you are using to develop your application?