?
Solved

JSP timing program and all hit the URL at the same time

Posted on 2005-03-04
9
Medium Priority
?
212 Views
Last Modified: 2011-09-20
hi!

I am trying to create some kind of JSP timing program and all hit the URL at the same time. So, I need an automated load testing tool. Does anyone has any idea?

BTW, this question is related the following question.
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21331239.html

thanks,
0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 92

Expert Comment

by:objects
ID: 13462722
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13463245
WebLoad from Radview http://www.radview.com/default.asp. You can download an evaluation version.

Or for a bigger enterprise system http://www.mercury.com/us/products/quality-center/functional-testing/winrunner/
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13463255
Or you write it yourself using HttpUrlConnection
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dkim18
ID: 13473969
All the links that you have provided me are too huge for this assignment. I am sure this isn't supposed to be a big project.
Would you mind reading my original question and advise me best solution for me? Actually, I am not even sure the above JSP will do test below.

anyway, here is my original question.
+++++++++++++++++++++
I am trying to create a test case that will definitively show which of the following three approaches a server uses for isThreadSafe=”false”:

*     Keeps a single servlet instance and queues up the requests to it.
*     Makes a pool of instances but lets each instance only handle one request at a time
*     Ignores inThreadSafe altogether.

So, "what do I need to do to distinguish among the three possible cases?") is precisely the point of this assignment.
SingleThreadModel is deprecated and using isThreadSafe="false" is equally bad in real life.

( Note all three approaches have been represented by Tomcat versions in the past.)
The isThreadSafe attribute controls whether the servlet that results from the JSP page will allow concurrent access (the default) or will guarantee that no servlet instance processes more than one request at a time (isThreadSafe=”false”).
+++++++++++++
thanks,
0
 
LVL 29

Accepted Solution

by:
bloodredsun earned 1000 total points
ID: 13474843
Right, here's a class that allows you to read the output of a webserver by setting up sequential connections to it. It shoudl be easy for you to modify it so that it sends multiple "similtaneous" requests to the same page.

---------------------
package com.bloodredsun;

import java.io.*;
import java.net.*;

public class Test {

      public static void main(String[] args) {
            
            //set up your urls array
            String[] urls = {"http://localhost:8080/webapp/one.jsp", "http://localhost:8080/webapp/two.jsp" };
            //you don't need this sb but you could something with it if you wanted
            StringBuffer sb = new StringBuffer();
            while(true){//loop forever
                  for( int jj=0 ; jj < urls.length ; jj++){
            
                        try {
                              //set up HttpURLConnection
                              URL u = new URL( urls[jj] );
                              HttpURLConnection huc = (HttpURLConnection) u.openConnection();
                              huc.setRequestMethod( "GET" );
                              huc.connect();
                              BufferedReader br = new BufferedReader(new InputStreamReader(huc.getInputStream()));

                              int b = 0;
                              while((b = br.read()) != -1) {
                                 sb.append((char)b);
                              }
                              br.close();
                              // disconnect HttpURLConnection
                              huc.disconnect() ;
                        }catch (IOException e){
                              System.out.println( "Unable to open connection: " + e.getMessage() );
                        }//end try/catch connection
                        try {
                              Thread.sleep( 1000 * 1 ) ;// every 1 second
                        } catch (InterruptedException e) {
                              e.printStackTrace();
                        }//end try/catch Thread.sleep
                  }//end for
            }//end while
      }//end main
}//end class


0
 

Author Comment

by:dkim18
ID: 13476239
Hm...when I excuted this, it hung. (I inserted same jsp pages in urls array.)
You created array of urls and put thread in sleep, but how does it send multiple simultaneous requests to the same page??

BTW, what possible results can I get? Based on the results, how do I decide which of the following those three approaches a server uses for isThreadSafe=”false”?
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13476339
It doesn't. You need to do that. It only requires a bit of tuning from you to make the class make simultaneous requests. It would just require you to repeat what I've done in the method and make some more connections for each loop

It doesn't hang. It just doesn't do anything apart from hit the jsps. IF you add

System.out.println("done: " + new Date());

just below

huc.disconnect() ;

you will see that it is making successful connections (don't forget to import java.util.Date at the top).

>>BTW, what possible results can I get?
This is just a way to hit the jsps, not a way of answering your question in a different TA, sorry.

What sort of assignment is this for?

0
 

Author Comment

by:dkim18
ID: 13477339
thanks for your help. I added some more urls and ran for two mininutes and date and time printed for each second.(a couple of seconds were skipped during excution.) Now, I have to create JSP page that does that and is it possible to create public class in JSP page?

This assignment is for just creating test case that distinguishes among those three possible cases and see what school server does in that case.
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13477472
Yes it is but the easiest thing to do would be to cut and past the body of the main method into a scriplet in a JSP if that's what you want to do.

I'm sorry I can't do much more than answer your question for you but my hands are tied as regards to doing homework/graded assignments, http://www.experts-exchange.com/help.jsp#hi56, but I'm glad to do that I've helped.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question