This Domain(Admin5.com) is for Sale:

八、设置HTTP应答头

时间:2007-10-22  来源:不详  作者:林子

primeListVector.removeElementAt(0);
primeListVector.addElement(primeList);
}
}
Vector currentPrimes = primeList.getPrimes();
int numCurrentPrimes = currentPrimes.size();
int numPrimesRemaining = (numPrimes - numCurrentPrimes);
boolean isLastResult = (numPrimesRemaining == 0);
if (!isLastResult) {
response.setHeader("Refresh", "5");
}
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Some " numDigits "-Digit Prime Numbers";
out.println(ServletUtilities.headWithTitle(title)
"<BODY BGCOLOR=\"#FDF5E6\">\n"
"<H2 ALIGN=CENTER>" title "</H2>\n"
"<H3>Primes found with " numDigits
" or more digits: " numCurrentPrimes ".</H3>");
if (isLastResult)
out.println("<B>Done searching.</B>");
else
out.println("<B>Still looking for " numPrimesRemaining
" more<BLINK>...</BLINK></B>");
out.println("<OL>");
for(int i=0; i<numCurrentPrimes; i ) {
out.println(" <LI>" currentPrimes.elementAt(i));

本文来自织梦


}
out.println("</OL>");
out.println("</BODY></HTML>");
}

public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}

// 检查是否存在同类型请求(已经完成,或者正在计算)。
// 如存在,则返回现有结果而不是启动新的后台线程。
private PrimeList findPrimeList(Vector primeListVector,
int numPrimes,
int numDigits) {
synchronized(primeListVector) {
for(int i=0; i<primeListVector.size(); i ) {
PrimeList primes = (PrimeList)primeListVector.elementAt(i);
if ((numPrimes == primes.numPrimes()) &&
(numDigits == primes.numDigits()))
return(primes);
}
return(null);
}
}
}

   PrimeNumbers.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>大素数计算</TITLE>
</HEAD>
<CENTER>
<BODY BGCOLOR="#FDF5E6">
<FORM ACTION="/servlet/hall.PrimeNumbers">

看完这篇,您有何感觉呢?

上一篇:九、处理Cookie   下一篇:七、HTTP应答状态

文章评论

共有位Admini5网友发表了评论 查看完整内容