JSP复习题4含答案

美斯坦福在线考试系统 G2T54 JSP科目: SCCEG2JSP总分: 100分时间: 60分钟一、单选题 (共45题,每题2分,说明:选择一项正确的答案)1、假设在helloapp应用中有一

美斯坦福在线考试系统 G2T54 JSP
科目: SCCEG2JSP总分: 100分时间: 60分钟




一、单选题 (共45题,每题2分,说明:选择一项正确的答案)

1、
假设在helloapp应用中有一个hello.jsp,文件路径为C:/Tomcat/webapps/helloapp/hello/hello.jsp那么在浏览器端访问hello.jsp的URL是(
)




A、http://localhost:8080/hello.jsp
B、http://localhost:8080/helloapp/hello.jsp
C、http://localhost:8080/helloapp/hello/hello.jsp
D、http://localhost:8080/helloapp/hello
参考答案: C





2、
下面不属于Servlet生命周期阶段的是( )




A、加载
B、实例化
C、初始化
D、请求资源
参考答案: D





3、
在Servlet中,HttpServletResponse的( )方法用来把一个HTTP请求重定向到另外的URL




A、sendURL()
B、redirectURL()
C、sendRedirect()
D、redirectResponse()
参考答案: C





4、
HttpServletRequest接口的( )方法用于创建会话




A、getSession()
B、getServletContext()
C、setSession();
D、putSession();
参考答案: A





5、
不同的客户端需要共享的信息应存储到( )中




A、ServletContext
B、Session
C、Request
D、Response
参考答案: A





6、
Cookie默认保存在( )目录下




A、Tomcat/Webapps/Cookies
B、系统目录/program files/Cookies
C、系统目录/documents and settings/Cookies
D、由写Cookie的程序决定
参考答案: C





7、
给定某servlet程序的片段如下:
public void doGet(HttpServletRequest
request,HttpServletResponse response)throws
ServletException,IOException{
PrintWriter out=response.getWriter();
out.println(“this is a servlet output”);
response.sendRedirect(“/hello.jsp”);
out.close();
}
并且该web应用下存在hello.jsp,该文件源码如下:

out.println(“hello wo

标签: