<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title heretitle> head> <body>
body> html> |
2.2.1 JSP脚本片段
<% System.out.println("Hello World");%> |
2.2.2 JSP表达式
<%=str %> |
<%! private int a = 0; %> |
2.2.4 注释
<%-- 注释内容 --%> |
|
JSP注释 |
Java注释 |
HTML注释 |
JSP页面 |
可见 |
可见 |
可见 |
Java代码 |
不可见 |
可见 |
可见 |
浏览器 |
不可见 |
不可见 |
可见 |
package org.apache.jsp;
import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*;
public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent {
private int a = 0; //JSP声明生成的代码 private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
private static java.util.List _jspx_dependants;
private javax.el.ExpressionFactory _el_expressionfactory; private org.apache.AnnotationProcessor _jsp_annotationprocessor;
public Object getDependants() { return _jspx_dependants; }
public void _jspInit() { _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName()); }
public void _jspDestroy() { }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException {
PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null;
try { response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out;
out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write(" out.write("\r\n"); out.write("\r\n"); out.write("\t");
System.out.println("Hello World"); //脚本片段生成的代码 int x = 20394; //脚本片段生成的代码
out.write("\r\n"); out.write("\t\r\n"); out.write("\t\r\n"); out.write("\t\r\n"); out.write("\t"); out.print(x ); out.write("\r\n"); out.write("\t\r\n"); out.write("\t"); out.write("\r\n"); out.write("\r\n"); out.write(""); } catch (Throwable t) { if (!(t instanceof SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) {} if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else log(t.getMessage(), t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } } |
|
<servlet> <servlet-name>jspservlet-name> <servlet-class>org.apache.jasper.servlet.JspServletservlet-class> <init-param> <param-name>forkparam-name> <param-value>falseparam-value> init-param> <init-param> <param-name>xpoweredByparam-name> <param-value>falseparam-value> init-param> <load-on-startup>3load-on-startup> servlet>
<servlet-mapping> <servlet-name>jspservlet-name> <url-pattern>*.jspurl-pattern> servlet-mapping>
<servlet-mapping> <servlet-name>jspservlet-name> <url-pattern>*.jspxurl-pattern> servlet-mapping>
|
PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; |
2.5.1 域对象
2.5.2 其他隐含对象
org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request);
2.6.1 page指令
2.6.2 include指令
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" errorPage="error.jsp"%> <%@ include file="in.html" %> DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title heretitle> head> <body>
body> html> |
DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title heretitle> head> <body> <h1>Hello I'm in.html Pageh1> body> html> |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" errorPage="error.jsp"%>
DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title heretitle> head> <body>
body> html> |
2.6.3 taglib指令
<jsp:forward page="target.jsp">jsp:forward> |
<jsp:forward page="target.jsp"> <jsp:param value="paramValue" name="paramName"/> jsp:forward> |
<jsp:include page="target.jsp">jsp:include> |
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "target.jsp", out, false);