Avatar billede fredand Forsker
11. september 2001 - 09:05 Der er 8 kommentarer og
1 løsning

Click to much on a link in jsp makes the app hang!

Hello amigos!

I got a problemo, I have developed a site with JSP-code and this run on a orion-server.

The problem is that the application, the site, hang if a visitor clicks several times on a link before the server as manage to return the answerpage.

So if some one know how to eliminate this problem, please let me know. I do not think that the answer is to by a faster server.

Best regards

Fredrik
Avatar billede disky Nybegynder
11. september 2001 - 09:08 #1
that is weird.

How is the link made ?

I never had the problem with either Resin,Tomcat og Oracle 9ias server.

Maybe it is a bug in orion.
Avatar billede fredand Forsker
11. september 2001 - 09:26 #2
Hello!

The strange thing is that the code or perhaps I should say form-submit isn\'t stranger than this.

<form action=\"subscription_answer.jsp\" name=\"magazine\" method=\"post\">
...bla bla etc
<td colspan=\"2\" class=\"bread\" colspan=\"2\" valign=\"top\">
<input type=\"submit\" value=\"Skicka in\">&nbsp;<input type=\"Reset\" value=\"Rensa\">
</td>
</form>

A link can look like this with jsp-tags but the code below mighy be hard to understand. But in the below section in the bottom the html-link can be viewed:

    <jsp:useBean id=\"myObject\" class=\"se.flowinteractive.aller.object.MyObject\"/>
    <%   
        String userid = (String)session.getAttribute(Constants.USERID);
        Vector vector;
        //Fetch the active Standard Object for sub
        if (userid != null && !(Integer.parseInt(userid) < 1))
        {
            if(session.getAttribute(Constants.PREVIEW_OBJECT) != null)
            {
                myObject = (MyObject) session.getAttribute(Constants.PREVIEW_OBJECT);
            }
            else
            {
                vector = ObjectHandler.getActivePrevSubObjects(Constants.OBJECT_TYPE_STANDARD, filepost.getTikd());
                if(vector.size() >= 1)
                {
                    myObject = (MyObject) vector.elementAt(0);
                    ObjectHandler.countDisplayedObject(myObject.getObjectcode(),myObject.getTikd(), session);
                }
            }
        }
        //Fetch the active Standard Object for none-sub
        else
        {
            vector = ObjectHandler.getActiveNotPrevSubObjects(Constants.OBJECT_TYPE_STANDARD, filepost.getTikd());
            if(vector.size() >= 1)
            {
                myObject = (MyObject) vector.elementAt(0);
                ObjectHandler.countDisplayedObject(myObject.getObjectcode(),myObject.getTikd(), session);
            }
           
        }
       
       
    %>
   
    <tr>
        <td valign=\"top\" colspan=\"3\">
            <table border=\"0\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#000000\">
                <tr>
                    <td bgcolor=\"#FFFFFF\">
                        <table width=\"500 border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
                            <tr>
                                <td valign=\"top\"><%if(myObject != null && myObject.getPicsrc() != null && !myObject.getPicsrc().equals(\"\")){%><img src=\"<mt:getContext/><jsp:getProperty name=\"myObject\" property=\"picsrc\"/>\" border=\"0\" alt=\"<jsp:getProperty name=\"myObject\" property=\"pictext\"/>\"><%}%></td>
                                <td width=\"10\" nowrap>&nbsp;</td>
                                <td class=\"bread\" width=\"500\" valign=\"top\">
                                    <font class=\"headline\"><jsp:getProperty name=\"myObject\" property=\"headline\"/></font><p>
                                    <jsp:getProperty name=\"myObject\" property=\"textvalue\"/><p>
                                    <table border=\"0\" cellpadding=\"4\" cellspacing=\"0\">
                                    <ot:iterate id=\"smallObject\" type=\"se.flowinteractive.aller.object.Offer\" collection=\"<%=myObject.getOffers()%>\">
                                        <tr>
                                            <td valign=\"top\"><img src=\"img/circle_unactive.gif\" name=\"<jsp:getProperty name=\"smallObject\" property=\"smallObjectcode\"/>\" border=\"0\"></td><td valign=\"top\"><a href=\"order_subscriber.jsp?tikd=<jsp:getProperty name=\"myObject\" property=\"tikd\"/>&kjkd=<jsp:getProperty name=\"myObject\" property=\"objectcode\"/>&erbj=<jsp:getProperty name=\"smallObject\" property=\"smallObjectcode\"/>\" target=\"main\" onFocus=\"this.blur()\" onmouseOver=\"document.<jsp:getProperty name=\"smallObject\" property=\"smallObjectcode\"/>.src=\'img/circle_active.gif\'; return true\" onmouseOut=\"document.<jsp:getProperty name=\"smallObject\" property=\"smallObjectcode\"/>.src=\'img/circle_unactive.gif\'; return true\"><jsp:getProperty name=\"smallObject\" property=\"text\"/></a></td>
                                        </tr>
                                    </ot:iterate>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>

Best regards

Fredrik
Avatar billede disky Nybegynder
11. september 2001 - 09:29 #3
hmmm.

maybe the code being executed when clicking the link is to slow.

But i wonder why the server hangs, when clicked more than once.

Maybe make a normalt html link, that sends you to a new page, which then calls the funcionality.

So that the user can\'t see the link anymore.
Avatar billede martin_schou Nybegynder
12. september 2001 - 10:41 #4
A shot in the fog:
Is the program activated by the link by any chance reading and writing into the same data source and running seperate threads to handle each request?

It _could_ be an x-lock problem, meaning that the program tries to access data, that the other thread(s) are using and vice versa.
Avatar billede fredand Forsker
12. september 2001 - 10:48 #5
Hello Martin!

Thanks for your reply.

The database solution got a pool of connections, and with my humble knowledge I thought that that means that the x-lock wouldn\'t occur. But I might be wrong.

I also guess that a Servlet (jsp-page) execute one request in a time from a stack or something, as the request come in? I also guess that the System (the orion-server) doesn\'t create more than one instace of a servlet and then let that instance pull works from the stack, but i might be wrong here as well?

Regards

Fredrik
Avatar billede disky Nybegynder
12. september 2001 - 10:49 #6
I am pretty sure the server would try to handle as many request as possible.

So you could easily have 10\'s of instances of the same servlet, except if you used a singleton pattern.

Yes if the connection pool is programmed correctly, there should not be a problem.
Avatar billede fredand Forsker
12. september 2001 - 11:00 #7
Hello Disky!

Thanks for your reply!

Okej, I see, then I guess that the System acctually could run out dataresource if it tries to create a lot of instances of a servlet.

Hmm, then I guess that I have to go throug the architecture again.

Thanks!

By the way you guys doesn\'t happens to know anything about networks caches in networks with proxies and firewalls. I heard that thoose might be horn in the side for a hard request to the real server, and sometime refuse to call the real server for the real page (suppose that you post to the same page) and return tha page that the proxy have stored in it\'s cache?

If it is so we now try to add this into every link:
<a href=\"somelink\"?time=<%=System.currentTimeMillis()%> so that the link never would be the same.

Perhaps that is basic knowledge, I do not know? But it would begreat with a comment.

Thanks

Fredrik
Avatar billede disky Nybegynder
12. september 2001 - 11:03 #8
Hi again

Add this in the top of every jsp page:

    response.setDateHeader(\"Expires\", 0);
    response.setHeader(\"Pragma\", \"no-cache\");
    response.setHeader(\"Cache-Control\", \"no-cache\");

It prevents browsers and proxies from caching the page.

Should help the problem.
Avatar billede fredand Forsker
12. september 2001 - 11:06 #9
Thanks amigo!

I should try it at once!!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester