Performance Issue: JSP response rendering

Discussion in 'Java' started by parkarumesh@gmail.com, Oct 8, 2007.

  1. Guest

    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
    , Oct 8, 2007
    #1
    1. Advertising

  2. Juha Laiho Guest

    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.
    --
    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)
    Juha Laiho, Oct 8, 2007
    #2
    1. Advertising

  3. Guest

    On Oct 8, 11:37 am, Juha Laiho <> wrote:
    > 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.
    > --
    > 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.
    , Oct 8, 2007
    #3
  4. vijayexist

    Joined:
    Jun 7, 2010
    Messages:
    1
    same issue

    Hi friends even I am facing the same prob
    can any body help me:withstup:
    vijayexist, Jun 7, 2010
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Spotnick
    Replies:
    3
    Views:
    10,646
    JeremyReid
    Oct 8, 2008
  2. ohaya
    Replies:
    0
    Views:
    4,079
    ohaya
    Jun 30, 2005
  3. Peter Mount
    Replies:
    4
    Views:
    932
    Peter Mount
    Jan 31, 2006
  4. Replies:
    0
    Views:
    4,335
  5. André
    Replies:
    3
    Views:
    1,887
    André
    Dec 1, 2006
Loading...

Share This Page