JSP[4]

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

本文简介:选择自 lemonade 的 blog

<% response.setcontenttype("text/plain"); %>

  • isthreadsafe="true|false". a value of true (the default) indicates normal servlet processing, where multiple requests can be processed simultaneously with a single servlet instance, under the assumption that the author synchronized access to instance variables. a value of false indicates that the servlet should implement singlethreadmodel, with requests either delivered serially or with simultaneous requests being given separate servlet instances.
  • session="true|false". a value of true (the default) indicates that the predefined variable session (of type httpsession) should be bound to the existing session if one exists, otherwise a new session should be created and bound to it. a value of false indicates that no sessions will be used, and attempts to access the variable session will result in errors at the time the jsp page is translated into a servlet.
  • buffer="sizekb|none". this specifies the buffer size for the jspwriter out. the default is server-specific, but must be at least 8kb.
  • autoflush="true|false". a value of true, the default, indicates that the buffer should be flushed when it is full. a value of false, rarely used, indicates that an exception should be thrown when the buffer overflows. a value of false is illegal when also using buffer="none".
  • extends="package.class". this indicates the superclass of servlet that will be generated. use this with extreme caution, since the server may be using a custom superclass already.
  • info="message". this defines a string that can be retrieved via the getservletinfo method.
  • errorpage="url". this specifies a jsp page that should process any throwables thrown but not caught in the current page.
  • iserrorpage="true|false". this indicates whether or not the current page can act as the error page for another jsp page. the default is false.
  • language="java". at some point, this is intended to specify the underlying language being used. for now, don't bother with this since java is both the default and the only legal choice.
  • the xml syntax for defining directives is
    <jsp:directive.directivetype attribute=value />
    
    for example, the xml equivalent of
    <%@ page import="java.util.*" %>
    is
    <jsp:directive.page import="java.util.*" />

    5.2 the jsp include directive

    this directive lets you include files at the time the jsp page is translated into a servlet. the directive looks like this:
    <%@ include file="relative url" %>
    
    the url specified is normally interpreted relative to the jsp page that refers to it, but, as with relative urls in general, you can tell the system to interpret the url relative to the home directory of the web server by starting the url with a forward slash. the contents of the included file are parsed as regular jsp text, and thus can include static html, scripting elements, directives, and actions.

    for example, many sites include a small navigation bar on each page. due to problems with html frames, this is usually implemented by way of a small table across the top of the page or down the left-hand side, with the html repeated for each page in the site. the include directive is a natural way of doing this, saving the developers from the maintenance nightmare of actually copying the html into each separate file. here's some representative code:

    <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
    <html>
    <head>
    <title>servlet tutorial: javaserver pages (jsp) 1.0</title>
    <meta name="author" content="webmaster@somesite.com">
    <meta name="keywords" content="...">
    <meta name="description" content="...">
    <link rel=stylesheet
          href="http://dev.csdn.net/article/7/site-styles.

    本文关键:JSP
      相关方案
    Google
     

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

    go top