博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Head First Servlet and JSP 笔记 JSP 部分 (未完待续)
阅读量:4604 次
发布时间:2019-06-09

本文共 3631 字,大约阅读时间需要 12 分钟。

第七章

1、

The Container takes what you’ve written in your JSP, translates it into a servlet class source (.java) file, then compiles that into a Java servlet class. 

2、

 you can put regular old Java code in a JSP using a scriptlet—which just means Java code within a <% ... %> tag. 

3、

Use the page directive to import packages 

To import a single package:

<%@ page import=”foo.*” %> 

To import multiple packages:

<%@ page import=”foo.*,java.util.*” %> 

4、

Expression <%= %> 

NEVER end an expression with a semicolon! 

5、

declaration <%! int count=0; %> 

JSP declarations are for declaring members of the generated servlet class. That means both variables and methods! In other words, anything between the <%! and %> tag is added to the class outside the service method. That means you can declare both static variables and methods. 

6、隐式对象

 

 

6、

<!-- HTML comment --> 

<%-- JSP comment --%> 

 

7、

API for the generated servlet 

jspInit()

This method is called from the init() method.

You can override this method. (Can you figure out how?)

jspDestroy()

This method is called from the servlet’s destroy() method. You can override this method as well. 

 

8、

Initializing your JSP 

Configuring servlet init parameters 

MyTestInit
/TestInit.jsp
email
ikickedbutt@wickedlysmart.com
MyTestInit
/TestInif.jsp

Overriding jspInit() 

<%!public void jspInit() {ServletConfig sConfig = getServletConfig();;String emailAddr = sConfig.getInitParameter(“email”);;ServletContext ctx = getServletContext();;ctx.setAttribute(“mail”, emailAddr);; }%>

 

9、attribute in JSP

 

10、page attribute

Using the pageContext to find an attribute when you don’t know the scope <%= pageContext.findAttribute(“foo”) %> 

 

(未完待续)

转载于:https://www.cnblogs.com/wxy325/archive/2013/05/11/3072328.html

你可能感兴趣的文章
webbug3.0菜鸟笔记1
查看>>
数组相关函数
查看>>
Python 和其他编程语言数据类型的比较
查看>>
T2695 桶哥的问题——送桶 题解
查看>>
HTML5 表单
查看>>
Android群英传》读书笔记 (3) 第六章 Android绘图机制与处理技巧 + 第七章 Android动画机制与使用技巧...
查看>>
关于微信公众平台测试号配置失败的问题
查看>>
【NOIP2001】统计单词个数
查看>>
linux常用端口
查看>>
异常处理
查看>>
/proc/uptime详解
查看>>
如何建立合适的索引?
查看>>
acwing 651. 逛画展
查看>>
(待完成)qbxt2019.05 总结12 - 趣味题目 鹰蛋
查看>>
[2018/11/18] Java数据结构(2) 简单排序 冒泡排序 选择排序 插入排序
查看>>
关于WPF程序只运行一个实例的方法
查看>>
图论:点分治
查看>>
mysql
查看>>
C/C++ 知识点---sizeof使用规则及陷阱分析(网摘)
查看>>
java小程序 示例
查看>>