Performance Issue: JSP response rendering

P

parkarumesh

Hi All,

Our application has a dynamic left navigation tree where entities of
the tree a fetched from database, appropriate HTML structure is formed
for each node and is the string is then rendered on the JSP as JSP
response.

To elaborate, I am providing the following code snippet

In my leftnav.jsp

<%
LeftNavTree leftNavTree = new LeftNavTree();
%>

<%= leftNavTree.outputTree()%>


I have the function outputTree in LeftNavTree.java which builds the
tree structure and returns a string of the HTML structure which is
rendered on the browser.

A sample string is

<table>
<tr>
<td>
<a href="....">Entit1</a>
</td>
</tr>
</table>

This is just a sample for one node, the string which is getting
rendered is huge as number of entities are many and also there is
nesting amongst the nodes.

I have checked for the code on server-side, it takes merely 4-5
seconds. I have inserted the following code in the above mentioned JSP

<% long startTime = System.currentTimeMillis(); %>

<%= leftNavTree.outputTree()%>

<% long endTime = System.currentTimeMillis();
System.out.println("@@@@JSP Render Tree Time: "+ (endTime - startTime)
+" ms");
%>

But to render the complete on browser it takes more than 1 minute.

Why is that JSP is taking so long time to just render the HTML string?
Is it because browert(IE 6.0) is taking time to render this huge
string? Is it that DOM structure takes so much time to get rendered?

What is the reason behind such a behavior and what are the workarounds
for the same?

Any help is highly appreciated as my project schedule has hit a lot
due the performance issue.

Thanks in advance
 
J

Juha Laiho

(e-mail address removed) said:
Our application has a dynamic left navigation tree where entities of
the tree a fetched from database, appropriate HTML structure is formed
for each node and is the string is then rendered on the JSP as JSP
response.

You've already begun to distinguish what your problem is; just
continue further on that path. Hope this message helps in that.
To elaborate, I am providing the following code snippet

In my leftnav.jsp

<%
LeftNavTree leftNavTree = new LeftNavTree();
%>

<%= leftNavTree.outputTree()%>


I have the function outputTree in LeftNavTree.java which builds the
tree structure and returns a string of the HTML structure which is
rendered on the browser.

A sample string is

<table>
<tr>
<td>
<a href="....">Entit1</a>
</td>
</tr>
</table>

This is just a sample for one node, the string which is getting
rendered is huge as number of entities are many and also there is
nesting amongst the nodes.

I have checked for the code on server-side, it takes merely 4-5
seconds. I have inserted the following code in the above mentioned JSP

<% long startTime = System.currentTimeMillis(); %>

<%= leftNavTree.outputTree()%>

<% long endTime = System.currentTimeMillis();
System.out.println("@@@@JSP Render Tree Time: "+ (endTime - startTime)
+" ms");
%>

But to render the complete on browser it takes more than 1 minute.

.... so, you've shown that your JSP takes 4-5 seconds (which is a high time
in itself!). Yet what is dipslayed on browser takes a lot longer.
Now, where is the problem? In the JSP? No. In the generated HTML? Yes.
Why is that JSP is taking so long time to just render the HTML string?

How about cutting the JSP completely out of the question: save the page
to a local HTML file. Then load it locally with the browser. Is it still
slow (when it does not make any calls to the browser)? I assume it is
(and if it isn't, it may be some cache playing tricks).
Is it because browert(IE 6.0) is taking time to render this huge
string? Is it that DOM structure takes so much time to get rendered?

What is the reason behind such a behavior and what are the workarounds
for the same?

Whatever it is, it isn't dependent on your JSP or Java code; it's
dependent on what you generate to the browser. Somehow you've
managed to design a page structure that is extremely heavy for the
browser to render. What is needed is to look not at the JSP but
at the complete genrerated HTML and deduce what exactly makes it
heavy.
 
M

mark.donaghue

(e-mail address removed) said:


You've already begun to distinguish what your problem is; just
continue further on that path. Hope this message helps in that.
















... so, you've shown that your JSP takes 4-5 seconds (which is a high time
in itself!). Yet what is dipslayed on browser takes a lot longer.
Now, where is the problem? In the JSP? No. In the generated HTML? Yes.


How about cutting the JSP completely out of the question: save the page
to a local HTML file. Then load it locally with the browser. Is it still
slow (when it does not make any calls to the browser)? I assume it is
(and if it isn't, it may be some cache playing tricks).



Whatever it is, it isn't dependent on your JSP or Java code; it's
dependent on what you generate to the browser. Somehow you've
managed to design a page structure that is extremely heavy for the
browser to render. What is needed is to look not at the JSP but
at the complete genrerated HTML and deduce what exactly makes it
heavy.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)

FWIW, I've heard the IE has difficulty rendering extremely large
tables. I would give it a shot in another browser like Firefox and see
if you get similar results.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top