JSP[6]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 lemonade 的 blog

revious section) useful, this is a buffered version of printwriter called jspwriter. note that you can adjust the buffer size, or even turn buffering off, through use of the buffer attribute of the page directive. this was discussed in section 5. also note that out is used almost exclusively in scriptlets, since jsp expressions automatically get placed in the output stream, and thus rarely need to refer to out explicitly.

7.4 session

this is the httpsession object associated with the request. recall that sessions are created automatically, so this variable is bound even if there was no incoming session reference. the one exception is if you use the session attribute of the page directive (see section 5) to turn sessions off, in which case attempts to reference the session variable cause errors at the time the jsp page is translated into a servlet.

7.5 application

this is the servletcontext as obtained via getservletconfig().getcontext().

7.6 config

this is the servletconfig object for this page.

7.7 pagecontext

jsp introduced a new class called pagecontext to encapsulate use of server-specific features like higher performance jspwriters. the idea is that, if you access them through this class rather than directly, your code will still run on "regular" servlet/jsp engines.

7.8 page

this is simply a synonym for this, and is not very useful in java. it was created as a placeholder for the time when the scripting language could be something other than java.

8. actions

jsp actions use constructs in xml syntax to control the behavior of the servlet engine. you can dynamically insert a file, reuse javabeans components, forward the user to another page, or generate html for the java plugin. available actions include:
  • jsp:include - include a file at the time the page is requested. see section 8.1.
  • jsp:usebean - find or instantiate a javabean. see section 8.2 for an overview, and section 8.3 for details.
  • jsp:setproperty - set the property of a javabean. see section 8.4.
  • jsp:getproperty - insert the property of a javabean into the output. see section 8.5.
  • jsp:forward - forward the requester to a new page. see section 8.6.
  • jsp:plugin - generate browser-specific code that makes an object or embed tag for the java plugin. see section 8.7.
these actions are described in more detail below. remember that, as with xml in general, the element and attribute names are case sensitive.

8.1 the jsp:include action

this action lets you insert files into the page being generated. the syntax looks like this:
<jsp:include page="relative url" flush="true" />
unlike the include directive, which inserts the file at the time the jsp page is translated into a servlet, this action inserts the file at the time the page is requested. this pays a small penalty in efficiency, and precludes the included page from containing general jsp code (it cannot set http headers, for example), but it gains significantly in flexibility. for example, h

本文关键:JSP
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top