for (int i=0; i<100; i++) {
out.println("Data for " + i + " is " + method1() + " , " + method2() + ".<br>");
}
out.close();
StringBuffer buf = new StringBuffer();
for (int i=0; i<100; i++) {
buf.append("Data for ").append(i).append(" is ").append(method1());
buf.append(" , ").append(method2()).append(".<br>");
}
response.setContentLength(buf.length());
out.println(buf.toString());
out.close();
public void openFile( String fileName ) {
try {
someOtherMethodToOpenAFile( fileName );
} catch( FileNotFoundException e ) {
out.println( "Sorry... File not found." );
}
}
/* 'response' variable is an object of the
HttpServletResponse class.
*/
public void openFile( String fileName ) {
try {
someOtherMethodToOpenAFile( fileName );
} catch( FileNotFoundException e ) {
response.sendError( response.SC_NOT_FOUND );
}
}
<frameset rows="20%,*" cols="80%,*">
<frame name="Frame1" src="/servlet/someServlet">
<frame name="Frame2" src="/servlet/anotherServlet">
</frameset>
新闻热点
疑难解答