📄 complete_4.java
字号:
package questions.c17;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Complete_4 extends HttpServlet {
private static String letters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public void service( HttpServletRequest req,
HttpServletResponse res )
throws ServletException, IOException
{ PrintWriter out = res.getWriter( );
res.setContentType( "text/html" );
out.println( "<HTML>" );
out.println( "<BODY>" );
out.println( "<H3>The Cookie Collector</H3>" );
// insert code to get all the cookies in the request
if ( cookies.length < 1 ) {
out.println( "<p>No cookies in request." );
} else {
out.println( "<p>The request has cookies." );
out.println( "<pre><b>Cookie Value</b>" );
}
for ( int i = 0; i < cookies.length; i++ ) {
// insert code to print each cookie's name and value
}
out.println( "</p>" );
int n = (int) ( Math.random() * 26 );
// insert code to create the new cookie,
// set its age to be removed when the browser ends,
// and add it to the response
out.println( "<p>Adding cookie:" );
out.println( "<br> " + cookie.getName() +
" " + cookie.getValue() );
out.println( "</pre></p>" );
out.println( "<p><a href=http://localhost:8080/" +
"servlet/questions.c17.Complete_4>Repeat</a>" );
out.println( "</BODY>" );
out.println( "</HEAD>" );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -