📄 jsp-directives.xtp
字号:
<s1 title="JSP Directives"><objsummary/><s2 name='jsp' title='JSP Directives'><defun name=language title='<%@ page language="lang" %>' index=language><p>Sets the JSP script language to <var/lang/>. Defaults to Java.All JSP 1.0 implementations must support Java. Some implementations,like Resin, may support other scripting languages, e.g. JavaScript.</p></defun><defun name=import title='<%@ page import="package" %>' index=import><p>Adds to the Java package import list for the generated Java file.</p><note>Only relevant when using Java.</note></defun><defun name=errorPage title='<%@ page errorPage="path" %>' index=errorPage><p>Defines a page to display if an error occurs in the JSP page.</p><p>Robust applications can return informative error pages whensomething goes wrong in a file, for example if a database is overloaded.<var/path/> is returned as the response file. The error pagecan use the additional implicit variable <ahref='#exception'>exception</a> containing the thrown exception.</p><p><var/path/> is relative to the current page. Its root is relativeto the application root.</p><p>The error page itself can be a JSP page. If the error page is aJSP page, it can use the implicit variable <code/exception/> to getinformation about the thrown exception.</p></defun><defun name=isErrorPage title='<%@ page isErrorPage="true" %>' index='error page'><p>Gives an error page access to the <code/exception/> implicit variable.Default to false.</p><example title='errorpage.jsp'><%@ page isErrorPage="true" %><h1>Received error <%= exception.message %></h1></example></defun><defun name=include title='<%@ include file="path" %>' index='include, at translation'><p>Includes the raw file <var/path/> at translation time.</p><p>The include directive is a replacement for an SSI include (or the C'#include'). It includes the contents of the file at <var/path/> intothe JSP file. The included file is parsed as JSP, so it can haveactive elements like expressions, declarations and scriptlets.</p><p><var/path/> is relative to the current page, and its root is theapplication root.</p><example title='header.jsp'><html><head><title><%= title %></title></head><body color=white></example><example title='page.jsp'><% var title = "Hello, World"; %><%@ include file='header.jsp' %><h1><%= title %></h1></example></defun><defun name=buffer index='page buffer' title='<%@ page buffer=sizekb %>'><p>Gives the <var/size/> of the page buffer in kb or <var/none/> forno buffer. Default 8kb. If <code/buffer/> is <var/none/>, alloutput is immediately flushed. </p><p>JSP 1.0 gives page writers flexibility by buffering its outputbefore sending the response to HTTP. The buffering allows <ahref='#errorpage'>error recovery</a> and forwarding, even aftergenerating some content. Once the buffer has filled, it will beflushed. So applications must still detect their errors early.</p><p>The following example generates an XML document (for variety). Ifthe form's query is missing the 'name' parameter, it will redirect theresults.</p><example><?xml version='1.0'?><form><% if (request.form["name"] == null) pageContext.forward("redo-form.jsp"); for (var name in request.form) { out.print("<" + name + ">"); out.print(request.form[name]); out.println("</" + name + ">"); }%></form></example></defun><defun name=autoFlush index='page buffer' title='<%@ page autoFlush="true" %>'><p>Tells JSP to flush the page buffer when it fills.Default is true.</p><p>If autoFlush is false, the JSP engine will throw an exception ifthe buffer overflows.</p></defun><defun name=pagesession index='session' title='<%@ page session="true" %>'><p>Tells JSP that the page participates in a session. Defaults to true.</p><p>The session declaration makes the session implicit variableavailable to a JSP page.</p><p>If the page doesn't use sessions, it should set <code/session/> to false.</p><example><%@ page session="true" %><% session.value.count++;%><h1>Welcome, visitor <%= count %></h1;></example></defun><defun name=isThreadSafe index='synchronization' title='<%@ page isThreadSafe="true" %>'><p>Tells the JSP that multiple pages can execute in parallel.Defaults to true.</p><p>JSP pages are always responsible for synchronization of sharedvariables, such as the <code/session/> and <code/application/>variables. In some rare cases, a page may use servlet variables(created with a declaration), and be too lazy to handle thesynchronization.</p><p>Even with <code/isThreadSafe=false/>, the JSP engine may createmultiple instances of the JSP servlet. So the page author can neverabsolve herself of synchronization issues.</p><p>In the following example, a JSP engine might create 3 servletinstances of the page. So three calls to the same page may returncounts of 17, 3 and 398. In addition, the JSP engine is free todestroy and recreate the servlet at any time, essentially resettingthe counter to 0.</p><example><%@ page isThreadSafe="false" %><%! var count = 0; %><h1>Welcome, visitor <%= count++ %></example></defun><defun name=info title='<%@ page info="description" %>'><p>Gives a brief description for the page.</p></defun><defun name=contentType title='<%@ page contentType="description" %>'><p>Sets the content type and character encoding of the page.</p><p><code/contentType/> can also set the character encoding, forexample to utf-8. </p><example><%@ page contentType="text/plain; charset=utf-8" %><%! var count = 0; %><h1>Welcome, visitor <%= count++ %></example></defun><defun name=extends title='<%@ page extends="Java class" %>'><p>Changes the generated servlet's class.</p><p>In general, a filter is a better solution than using theextends directive.</p></defun><defun name=taglib title='<%@ taglib prefix="x" uri="foo" %>'><p>Configures tags with prefix <var/x/> to use the taglibrary <var/foo/>.</p><example><%@ taglib prefix='x' uri='http://www.caucho.com/mytag/test' %><x:mytag/></example></defun></s2></s1>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -