随笔分类 - Servlet & Jsp
摘要:servlet配置:<servlet> <servlet-name>test</servlet-name> <servlet-class>TestServlet</servlet-class> <init-param> <param-name>email</param-name> <param-value>1@163.com</param-value> </init-param>
</servlet>
<servlet-mapping> &
阅读全文
摘要:<jsp:include>标准动作可以在一个页面中包含另一个页面,例如:<html> <body> <jsp:include page="Header.jsp" /> </body></html>include指令也可以实现这种功能,例如:<html> <body> <%@ include file="Header.jsp" %> </body></html>但两者原理有所不同,<jsp:include>标准动作
阅读全文
摘要:与bean相关的标准动作:<jsp:useBean id="person" class="foo.Person" scope="request" /><jsp:getProperty name="person" property="name" /><jsp:setProperty name="person" property="name" value="Fred" />jsp:useBean动作在没有
阅读全文
摘要:一个jsp页面最后变成一个servlet三个指令: page,include,taglib指令表示方式: <%@ page import="foo.*" %> import是page指令的一个属性五种种jsp元素: scriptlet:<% ... %> 指令:<%@ ... %> 表达式:<%= ... %> 声明:<%! ... %> 动作:<jsp:include page="wickedFooter.jsp" />表达式“=”后的内容会当做参数传递给打印语句,例如<%=
阅读全文
摘要:场景:你想知道一个web应用上下文中是否增加、删除或替换了一个属性监听者接口:javax.servlet.ServletContextAttributeListener attributeAdded attributeRemoved attributeReplaced事件类型:ServletContextAttributeEvent场景:你想知道有多少个并发用户,也就是说,你想跟踪活动的会话监听者接口:javax.servlet.http.HttpSessionListener sessionCreated sessionDestroyed事件类型:HttpSessionEvent场景:每次请
阅读全文
摘要:HttpSession对象可以保存同一个客户多个请求的会话状态容器如何知道客户是谁? 通过唯一的会话ID怎样得到会话?HttpSession session = request.getSession();如果找到与该请求匹配的会话,返回会话,如果没有,创建一个新会话客户和容器如何交换会话ID信息? 通过cookie,如果客户端cookie被禁用,则采用URL重写怎样知道会话是已经存在,还是刚刚创建?HttpSession session = request.getSession();
if (session.isNew) { // is a new session
}如果只想要一个...
阅读全文
摘要:http请求关键要素: 1.http方法(get,post)等 2.请求URL 3.参数http响应关键要素: 1.状态码 2.内容类型(MIME类型) 3.内容用post不用get的理由: 1.get携带数据量有限 2.get直接将查询串加到url后,安全性差 3.post不能被客户建立书签get是幂等操作,post不是幂等操作。servlet程序框架:import javax.servlet.*;import javax.servlet.http.*;import java.io.*;public class MyServlet extends HttpServlet { public v
阅读全文

浙公网安备 33010602011771号