⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preface.html

📁 struts api,学习使用struts必备的文档
💻 HTML
📖 第 1 页 / 共 3 页
字号:
    <a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/Servlets8.html#64572">Filtering Requests and Responses</a>
    </li>
    </ul>

      </div>
<h2 id="session">0.7.6 Sessions</h2>
<div class="indent">

      <p>One of the key characteristics of HTTP is that it is
      <em>stateless</em>. In other words, there is nothing built in to
      HTTP that identifies a subsequent request from the same user as being
      related to a previous request from that user. This makes building an
      application that wants to engage in a conversation with the user over
      several requests to be somewhat difficult.</p>

      <p>To alleviate this difficulty, the servlet API provides a programmatic
      concept called a <em>session</em>, represented as an object that
      implements the <code>javax.servlet.http.HttpSession</code> interface.
      The servlet container will use one of two techniques (cookies or
      URL rewriting) to ensure that the next request from the same user will
      include the <em>session id</em> for this session, so that state
      information saved in the session can be associated with multiple
      requests. This state information is stored in <em>session
      attributes</em> (in JSP, they are known as "session scope beans").</p>

      <p>To avoid occupying resources forever when a user fails to complete
      an interaction, sessions have a configurable <em>timeout interval</em>.
      If the time gap between two requests exceeds this interval, the session
      will be timed out, and all session attributes removed. You define a
      default session timeout in your web application deployment descriptor,
      and you can dynamically change it for a particular session by calling
      the <code>setMaxInactiveInterval()</code> method.</p>

      <p>Unlike requests, you need to be concerned about thread safety on
      your session attributes (the methods these beans provide, not the
      <code>getAttribute()</code> and <code>setAttribute()</code> methods
      of the session itself). It is surprisingly easy for there to be
      multiple simultaneous requests from the same user, which will therefore
      access the same session.</p>

      <p>Another important consideration is that session attributes occupy
      memory in your server <em>in between</em> requests. This can have
      an impact on the number of simultaneous users that your application can
      support. If your application requirements include very large numbers of
      simultaneous users, you will likely want to minimize your use of
      session attributes, in an effort to control the overall amount of memory
      required to support your application.</p>

      <p>
      For more about sessions, see:
      </p>
      <ul>
        <li>
        <a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/Servlets11.html#64744">Maintaining Client State</a> in Java Web Services Tutorial
        </li>
        <li>
        <a href="http://java.sun.com/products/servlet/2.1/api/javax.servlet.http.HttpSession.html">
<code>javax.servlet.http.HttpSession</code>
</a>
        </li>
      </ul>

      </div>
<h2 id="dispatch">0.7.7 Dispatching Requests</h2>
<div class="indent">

      <p>
      The Java Servlet specification extends the HTTP request/response cycle by allowing the request to be dispatched,
      or forwarded, between resources.
      Struts uses this feature to pass a request through specialized components,
      each handling one aspect of the response.
      In the normal course, a request may pass through a controller object, a model object,
      and finally to a view object as part of a single request/response cycle.
      </p>

      </div>
<h2 id="webapp">0.7.8 Web Applications</h2>
<div class="indent">

      <p>
      Just as a HTTP server can be used to host several distinct web sites,
      a servlet container can be used to host more than one web application.
      The Java servlet platform provides a well-defined mechanism for organizing and deploying web applications.
      Each application runs in its own namespace so that they can be developed and deployed separately.
      A web application can be assembled into a Web Application Archive, or WAR file.
      The single WAR can be uploaded to the server and automatically deployed.
      </p>

    <p>
    For more about web applications, see:
    </p>
    <ul>
    <li>
        <a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/WebApp.html#76431">Web Applications</a> in Java Web Services Tutorial
    </li>
    </ul>

      </div>
<h2 id="events">0.7.9 Web application deployment descriptor (web.xml)</h2>
<div class="indent">

      <p>
      Most aspects of an application's lifecycle are configured through an XML document called the Web application deployment descriptor.
      The schema of the descriptor, or web.xml, is given by the Java servlet specification.
      </p>

      <p>
      For more about the web.xml and application lifecycle events, see:
      </p>
      <ul>
      <li>
      <a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/WebApp2.html#64550">Web Application Life Cycle</a> in Java Web Services Tutorial
      </li>
      </ul>

      </div>
<h2 id="security">0.7.10 Security</h2>
<div class="indent">

    <p>
    One detail that can be configured in the Web application deployment descriptor is container-managed security.
    Declarative security can be used to protect requests for URIs that match given patterns.
    Pragmatic security can be used to fine-tune security make authorization decisions based on the time of day,
    the parameters of a call, or the internal state of a Web component.
    It can also be used to restrict authentication based on information in a database.
    </p>

      <p>For more information about container-managed security, see:</p>
      <ul>
      <li>
<a href="http://java.sun.com/webservices/docs/1.2/tutorial/doc/index.html">
          Web Application Security (Chapter 24)</a> in the Java Web Services Tutorial
      </li>
      </ul>

    </div>
<h2 id="jsp">0.8 JavaServer Pages, JSP Tag Libraries, and Java Server Faces</h2>
<div class="indent">
    <p>
<a href="http://java.sun.com/products/jsp/product.html">JavaServer Pages</a> (JSPs) are
    "inside-out servlets" that make it easier to create and maintain dynamic web pages. Instead
    of putting what you want to write to the HTTP response inside of a Java <code>print</code>
    statement, everything in a JavaServer Page is written to the response, <strong>except</strong> what is
    placed within special Java statements.</p>

    <p>With <strong>JavaServer Pages</strong> you can start by writing the page in standard HTML and then add the
    dynamic features using statements in the Java language or by using
    <a href="http://java.sun.com/products/jsp/taglibraries.html">JSP tags</a>.
    The Struts distribution includes several JSP tags that make it easy to access the framework's
    features from a JavaServer Page.</p>

    <p>For more about JavaServerPages and Custom JSP Tag Libraries see  </p>

    <ul>
    <li>
<a href="http://java.sun.com/products/jsp/">
<strong>The
        JavaServer Pages Technology</strong>
</a> page at
        <code>java.sun.com</code>
</li>
    <li>
<a href="http://java.sun.com/products/jsp/download.html">
<strong>The
        JSP 1.1 and 1.2 Specifications</strong>
</a> download page at
        <code>java.sun.com</code>
</li>
    <li>
<a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSPIntro.html">
<strong>JavaServer Pages Technology</strong>
</a> in the Java Web Services Tutorial</li>
    <li>
<a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSPTags.html">
<strong>Custom Tags in JSP Pages</strong>
</a> in the Java Web Services Tutorial</li>
    </ul>

    <p>Many times, JSP tags work hand-in-hand with JavaBeans. The application sends a JavaBean to
    the JSP, and the JSP tag uses the bean to customize the page for the instant user. For more, see
    <a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSPBeans.html">JavaBeans Components in JSP Pages</a>
    in the Java Web Services Tutorial.</p>

    <p>Struts also works well with the new
    <a href="http://java.sun.com/products/jsp/jstl">
<strong>JavaServer Pages Standard Tag Library</strong>
</a>
    (JSTL) and taglibs from other sources, like
    <a href="http://jsptags.com/">JSP Tags</a> and
    <a href="http://jakarta.apache.org/taglibs/index.html">Jakarta Taglibs</a>.
    </p>

    <p>
        One of the contributed libraries available for Struts is <strong>Struts-EL</strong>.
        This taglib is specifically designed to work well with JSTL.
        In particular, it uses the same "expression language" engine for evaluating tag attribute values as JSTL.
        This is in contrast to the original Struts tag library, which can only use "rtexprvalue"s (runtime scriptlet
        expressions) for dynamic attribute values.
    </p>

    <p>There are also toolkits available that make Struts easy to use with
    <a href="http://www.openroad.ca/opencode/">XSLT</a> and
    <a href="http://jakarta.apache.org/velocity/index.html">Velocity Templates</a>.
    </p>

        <p>
            The newest star on the Java horizon is <strong>Java Server Faces</strong>.
            <a href="http://java.sun.com/j2ee/javaserverfaces/">JavaServer Faces technology</a> simplifies building
            user interfaces for JavaServer applications, both for the web and for the desktop.
            The JSF specification is still under development, although an early-release reference implementation is
            available through the <a href="http://java.sun.com/webservices/download.html">Java Web Services Developer
            Pack</a>.
            Likewise, an early-release JavaServer Faces taglib for Struts,
            <a href="http://archive.apache.org/dist/jakarta/struts/old/release/struts-faces/">
<strong>Struts-Faces</strong>
</a>, is
            also in early release and available through the nightly build.
       </p>

        <p>
            Java Server Faces is very compatible with Struts.
            Additional Struts/JSF integration tools are sure to appear as the specification is finalized and comes into
            widespread use.
        </p>

        <p>For more about JSTL and JavaServer Faces see  </p>

       <ul>
           <li>
               <a href="http://today.java.net/pub/a/today/2003/10/07/jstl1.html">Practical JSTL, Part 1</a> by Sue Spielman
           </li>
           <li>
               <a href="http://www.jsfcentral.com">
<strong>JSF Central</strong>
</a> - JavaServer Faces resources.
            </li>
<li>
               <a href="http://www.jamesholmes.com/JavaServerFaces/">
<strong>JavaServer Faces Resources</strong>
</a> - James Holmes dot Com.
           </li>
       </ul>

    </div>
<h2 id="xml">0.9 Extensible Markup Language (XML)</h2>
<div class="indent">

    <p>The features provided by the Struts framework relies on a number of objects that are
    usually deployed using a configuration file written in
    <a href="http://www.w3.org/XML/">Extensible Markup Language</a>. XML is also used to
    configure Java web applications; so, this is yet another familiar approach.
    </p>

    <p>For more about XML configuration files and Java web applications, see</p>

    <ul>
    <li>
        <a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/WebApp4.html#64678">Configuring Web
        Applications</a> in the Java Web Services Tutorial</li>
    </ul>

    <p>
        For more about how XML is used with Java applications generally, see
        <a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/JAXPIntro.html">Java API for XML Processing</a>
        in the Java Web Services Tutorial.
        While the framework makes good use of this API internally, it is not something most Struts developers would use
        when writing their own applications.
    </p>

    </div>
<h2 id="descriptors">0.9.1 Descriptors</h2>
<div class="indent">

        <p>
        When Java applications use XML configuration files,
        the elements are most often used as <em>descriptors</em>.
        The application does not use the XML elements directly.
        The elements are used to create and configure (or deploy) Java objects.
        </p>

        <p>
        The Java Servlet platform uses an XML configuration file to deploy servlets (among other things).
        Likewise, Struts uses an XML configuration file to deploy objects used by the framework.
        </p>

    </div>
<h2 id="layers">0.10 Other layers</h2>
<div class="indent">

    <p>
      Struts provides the control layer for a web application. Developers can use this layer with
      other standard technologies to provide the data access and presentation layers. Some
      popular Data access technologies include:
    </p>

        <ul>
            <li>
<a href="http://java.sun.com/products/ejb/index.html">Enterprise Java Beans</a>
</li>
            <li>
<a href="http://sourceforge.net/projects/hibernate">Hibernate</a>
</li>
            <li>
<a href="http://sourceforge.net/projects/ibatisdb">iBATIS</a>
</li>
            <li>
<a href="http://java.sun.com/products/jdbc/index.html">JDBC</a>
</li>
            <li>
<a href="http://db.apache.org/ojb/">Object Relational Bridge</a>
</li>
        </ul>

    <p>
      Presentation layer technologies include:
    </p>

        <ul>
        <li>
<a href="http://java.sun.com/products/jsp">JavaServer Pages</a>
</li>
        <li>
<a href="http://jakarta.apache.org/velocity/index.html">Velocity Templates</a>
</li>
        <li>
<a href="http://www.w3.org/TR/xslt">XSL Transformations </a>
</li>
        </ul>

    </div>
<h2 id="jaas">0.11 JAAS</h2>
<div class="indent">

    <p>
        While Struts can work with any approach to user authentication and authorization, Struts 1.1 and later offers
        direct support for the standard Java Authentication and Authorization Service (JAAS).
        You can now specify security roles on an action-by-action basis.
    </p>

    <p>For more about JAAS, see the <a href="http://java.sun.com/products/jaas/index-14.html">Javasoft product page</a>
    and the <a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/WebAppSecurity.html">
    Web Application Security</a> chapter of the
    <a href="http://java.sun.com/webservices/docs/1.0/tutorial/index.html">Java Web Services Tutorial</a>.</p>

</div>
<hr class="section" />
<div class="indent">
    <p class="right">
    Next: <a href="introduction.html">Introduction</a>
    </p>
</div>
</div>
<!--end main-->
</div>
<!--end content-->
<div id="footer">
<img id="powered-logo" alt="Powered by Struts" src="../images/struts-power.gif" />
        Copyright (c) 2000-2005, The Apache Software Foundation <span class="noprint">- 
        <a href="http://wiki.apache.org/struts/StrutsDocComments">Comments?</a>
</span>
</div>
<!--end footer-->
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -