《JavaWeb编程技术》课后习题答案(7)
时间:2025-07-11
时间:2025-07-11
注意:如果代码写成下面形式:
<% int i; %>
<% for(i = 0; i<3; i++)%>The value of i is <%=i%>
输出结果将为:
The value of i is The value of i is The value of i is 3
10. 答:不能在japInit()方法中使用application对象。
11. 答:The sum of x and y is 9
变量x将被声明两次:一次是作为类的全局变量,因为使用了<%! int x = 5; %>语句,另一次是在_jspService()方法中声明的局部变量,因为使用的代码是<% int x = 3; %>。
12. 答:B 13. 答:C,E
14. 答:②③⑥④①⑤
15. 答:
out.write("<html><body>\r\n");
int count = 0 ;
out.write(" The page count is now:\r\n");
out.print( ++count );
out.write("</body></html>\r\n");
16. 答:
Page改为page
<%! int count = 0 %> // 声明缺少分号
<% count++; %> // 去掉分号
17. 答:D
18. 答:
<% Float one = new Float(88.88) %> 小脚本
<%! int y = 3; %> 声明
<%@ page import="java.util.*" %> 指令
<jsp:include page="foo.jsp" /> 动作
<%=pageContext.getAttribute("foo") %> 表达式
email:${applicationScope.mail} EL表达式
19. 答:A,B,C,E 20. 答:A,B,C,D
21. 答:D 22. 答:C
23. 答:
request (javax.servlet.http.HttpServletRequest)
response (javax.servlet.http.HttpServletResponse)
out (javax.servlet.jsp.JspWriter)
session (javax.servlet.http.HttpSession)
application (javax.servlet.ServletContext)
config (javax.servlet.ServletConfig)
exception (ng.Throwable )
pageContext (javax.servlet.jsp.PageContext)