JSP and JSTL Tutorials - Tutorial Addendum - JSP Achievement
| |
Calculating Prime Numbers
The first breadth I wish to analysis for achievement is accumulation addition calculations.
The afterward JSP page calculates prime amount starting from amount 3, and repeats
the analysis some times.
<?xml version="1.0"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
<!-- PrimeNumbers.jsp
Absorb (c) 2003 by Dr. Yang
-->
<jsp:directive.page contentType="text/html"/>
<jsp:directive.page import="java.util.*"/>
<jsp:scriptlet><![CDATA[
int[] primes = new int[1000];
int numberOfTests = 100;
int numberOfPrimes = 1000;
continued t1 = System.currentTimeMillis();
for (int nTest=1; nTest<=numberOfTests; nTest++) {
// Accepting prime numbers
int nPrime = 0;
int i = 2;
while (nPrime < numberOfPrimes) {
i = i + 1;
int j = 2;
boolean isPrime = true;
while (j<i && isPrime) {
isPrime = i % j > 0;
j = j + 1;
}
if (isPrime) {
nPrime = nPrime + 1;
primes[nPrime-1] = i;
}
}
}
continued t2 = System.currentTimeMillis();
continued t = t2 - t1;
// Announcement the results
out.println("<html><body>");
out.println("<b>Performace Information:</b><br/>");
out.println("Number of tests = " + numberOfTests + "<br/>");
out.println("Time = " + (t/1000) + " seconds.<br/>");
out.println("<b>" + numberOfPrimes + " prime numbers:</b><br/>");
for (int n = 1; n <= numberOfPrimes; n++) {
out.println(primes[n-1] + ", ");
}
out.println("</body></html>");
]]></jsp:scriptlet>
</jsp:root>
I run this page, and got the afterward result. It tells me the page is alive correctly.
Performace Information
Number of tests = 1
Time = 0 seconds
First 1000 Prime numbers:
3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, ...
By alteration the authoritative parameters, I was able to get some results:
Amount Amount Alter Time
Cases of Tests of Primes Approach (sec) Notes
1. 1 1000 Yes 25 ASP with IIS 5.0
2. 1 1000 No 25 ASP with IIS 5.0
3. 1 1000 ? 0 JSP with Bobcat 4.1.18
4. 10 1000 ? 2 JSP with Bobcat 4.1.18
5. 100 1000 ? 22 JSP with Bobcat 4.1.18
6. 100 1000 ? 21 JVM HotSpot 1.3.1
So this tells us that JSP pages are 100 times faster than ASP pages for
integer calculations.
(Continued on next part...)
|
println, nprime, prime, isprime, numberofprimes, primes, tests, tomcat, performance, notes, numberoftests, numbers, , < jsp, println <, jsp with, prime numbers, jsp with tomcat, jsp directive page, tutorials tutorial notes, jstl tutorials tutorial, |
Also see ...
i(Continued from antecedent part...)/iResponse Time of "Hello" PageThe next breadth I wish analysis is absolute acknowledgment time of ASP pages. To do this, I wroteth
This affiliate describes:HTTP Acknowledgment SyntaxHTTP Acknowledgment Attack LinesControlling Attack LinesViewing Attack Linesbr
i(Continued from antecedent part...)/i2. Acknowledgment attack lines: Advice about the response: Accept Ranges Age ETag Area
i(Continued from antecedent part...)/iOnce the Web browser finishes processing the article body, you can get some bound informationfrom the attack lines. For example, you can bang the appropriate abrasion button
i(Continued from antecedent part...)/i2. Command: "php HttpRequestGet.php /dot.gif" gives us: HTTP/1.1 200 OKServer: Microsoft IIS/5.1Date: Sun, 13 Nov 2005 04:40:17 GMTCon
i(Continued from antecedent part...)/iHere is the output: HTTP/1.1 200 OKServer: Microsoft IIS/5.1Date: Sat, 19 Nov 2005 02:28:32 GMTContent Type: text/xml;charset=utf 8br
i(Continued from antecedent part...)/iGenerating Non HTML Article BodySometimes, you may wish to forward aback advice in the article physique that are not in the HTML
i(Continued from antecedent part...)/iSending Files for DownloadingIn the antecedent section, the requested book is delivered to the browser for aperture immediately. p
This affiliate describes:What is a session.How use affair in a PHP script.A affair analysis with 3 scripts.How affair ID can be managed after
i(Continued from antecedent part...)/iSessionPage2.php: <?php SessionPage2.php Absorb (c) 2002 by Dr. Yang session_start(); $quantity = $_SESSION; $pr