註解 <%– 註解 –%>
指令 <%@ 指令 %>
宣告 <%! 宣告 %> 盡量不要用
程式片段<% 程式碼 %> 盡量不要用
運算式 <%=運算 %> 盡量不要用
JSP指令只有下面三種 page include taglib 例如:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
page的屬性有下列幾種
contentType="text/html;
pageEncoding="UTF-8")
這邊有一個errorpage的範例 excceptionpage.jsp
<%@ page session="false" isErrorPage="true" pageEncoding="UTF-8"
import="java.io.PrintWriter" %>
<%
String expTypeFullName
= exception.getClass().getName();
String expTypeName
= expTypeFullName.substring(expTypeFullName.lastIndexOf(".")+1);
String request_uri
= (String) request.getAttribute("javax.servlet.error.request_uri");
%>
<HTML>
<HEAD>
<TITLE>JSP Exception Page</TITLE>
</HEAD>
<BODY >
<%= expTypeName %>
<%= exception.getMessage() %>
這是 request URI: <BR>
<CODE><%= request_uri %></CODE>
This is the complete backtrace of the exception:
<PRE>
<% exception.printStackTrace(new PrintWriter(out)); %>
</PRE>
</BODY>
</HTML>
include指令-用來包含其他程式進來,可以少寫一些重複性的程式 例如header 或是footer之類的
include有分靜態跟動態兩種
靜態 <%@ include file="header.inc" %>
動態
靜態效能比較好
隱含物件(變數)
request response out session application config pageContext page ewexception