📄 webapp-tags.xtp
字号:
automatic | manual}</def></defun><defun title="Resource Tags" version="Resin 3.1"><parents>cluster, host, web-app</parents><p>See the <a href="env-tags.xtp">Resource tag documentation</a> for a full list of resources available to the web-app.</p><p>All resource tags are available tothe <web-app>, like databases, IoC beans and components, EJB stateful,stateless and message beans, JMS queues, remote clients, etc.</p><example title="Example: web-app database in resin-web.xml"><web-app xmlns="http://caucho.com/ns/resin"> <database jndi-name="jdbc/test"> <driver type="org.postgresql.Driver"> <url>jdbc:postgresql://localhost/test</url> <user>caucho</user> </driver> </database></web-app></example><p>Or <a href="ioc-bean.xtp">IoC-configured Beans</a>:</p><example title="Example: IoC bean in resin-web.xml"><web-app xmlns="http://caucho.com/ns/resin"> <bean jndi-name="jdbc/test" type="example.Theater> <init name="Balboa Theater"> <movie title="Attack of the Killer Tomatoes"/> <movie title="Snakes on a Plane"/> <movie title="Casablanca"/> </init> </bean></web-app></example></defun><defun title="<rewrite-dispatch>" version="Resin 3.1"><parents>cluster, host, web-app</parents><p><rewrite-dispatch> defines a set of rewriting rules fordispatching and forwarding URLs. Applications can use these rulesto redirect old URLs to their new replacements.</p><p>See <a href="rewrite-tags.xtp">rewrite-dispatch</a> for moredetails.</p><example title="Example: Mediawiki dispatch in resin-web.xml"><web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <dispatch regexp="\.(php|gif|css|jpg|png)"/> <forward regexp="^" target="/index.php"/> </rewrite-dispatch></web-app></example></defun><defun title="<rewrite-real-path>" version="Resin 3.1"><parents>cluster, host, web-app</parents><p><rewrite-real-path> lets you rewrite the URL to physical pathmapping, to allow aliasing or for filesystem organization.</p><deftable title="<rewrite-real-path> Attributes"><tr> <th>Attribute</th> <th>Description</th></tr><tr> <td>real-path</td> <td>specifies the URL to real-path mapping</td></tr><tr> <td>regexp</td> <td>a regular expression matching a URL</td></tr><tr> <td>replacement</td> <td>specifies a replacement pattern for URL to URL rewriting</td></tr><tr> <td>rewrite</td> <td>rewrites a URL to another URL as a preprocessing-step</td></tr><tr> <td>target</td> <td>specifies the target for URL to real-path mapping</td></tr></deftable><def title="<rewrite-real-path> schema">element rewrite-real-path { element rewrite { regexp & replacement }* & element rewrite { regexp & target }*}</def><example title="Example: aliasing /foo to /bar"><web-app xmlns="http://caucho.com/ns/resin"> <rewrite-real-path> <real-path regexp="^/foo" target="/bar"/> </rewrite-real-path></web-app></example></defun><defun title="<root-directory>" version="Resin 3.1"><p><root-directory> configures the web-app's filesystem root.</p><def title="<root-directory> schema">element root-directory { string}</def></defun><defun title="<secure>"><parents>web-app</parents><p>The <secure> flag requires that the web-app only be accessedin a secure/SSL mode. Equivalent to a <security-constraint>.</p><def title="<secure> schema">element secure { r_boolean-Type}</def></defun><defun title="<security-constraint>" version="Servlet"><parents>web-app</parents><p>Specifies protected areas of the web site. Sites usingauthentication as an optional personalization feature will typicallynot use any security constraints. See <a href="resin-security.xtp">Resinsecurity</a> for an overview.</p><p>Security constraints can also be custom classes.</p><p>See <a href="resin-security.xtp">Resin security</a> for an overview ofsecurity issues and configuration.</p><deftable title="<security-constraint> Attributes"><tr> <th>Attribute</th> <th>Description</th></tr><tr> <td>auth-constraint</td> <td>Defines a security condition based on a logged-in user's role</td></tr><tr> <td>constraint</td> <td>Defines a custom security condition</td></tr><tr> <td>ip-constraint</td> <td>Defines a security condition based the remote IP address</td></tr><tr> <td>role-name</td> <td>Defines role-name requirement</td></tr><tr> <td>url-pattern</td> <td>URL pattern to match the security constraint</td></tr><tr> <td>user-data-constraint</td> <td>Defines SSL or non-SSL requirements</td></tr><tr> <td>web-resource-collection</td> <td>URL patterns and HTTP methods defining the constraint</td></tr></deftable><def title="<security-constraint> content">element security-constraint { auth-constraint* & constraint* & ip-constraint* & role-name* & user-data-constraint* & url-pattern? & web-resource-collection*}</def><example title="Example: 'user' role required in WEB-INF/resin-web.xml"><web-app xmlns="http://caucho.com/ns/resin"><security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint role-name='user'></security-constraint></web-app></example></defun><defun title="<servlet>" version="Servlet 2.2"><p>Defines a servlet to process HTTP URL requests. The servlet classcan either implement <a href="http://caucho.com/resin-javadoc/javax/servlet/Servlet.html">javax.servlet.Servlet</a> to handle the HTTP requestdirectly or it can use a <a href="resin-remoting.xtp">remoting</a>protocol like SOAP or Hessian to handle remoting requests.</p><p>Since servlets are full <a href="resin-ioc.xtp">Resin-IoC</a> beans,they can use dependency injection, EJB aspects like @TransactionAttribute,custom @InterceptorType interceptors, and listen for @Observes events.</p><deftable title="<servlet> Attributes"><tr> <th>Attribute</th> <th>Description</th></tr><tr> <td>init</td> <td><a href="resin-ioc.xtp">Resin-IoC</a> initialization</td></tr><tr> <td>init-param</td> <td>Initialization parameters</td></tr><tr> <td>load-on-startup</td> <td>Initializes the servlet when the server starts.</td></tr><tr> <td>protocol</td> <td>Protocol configuration for <a href="resin-remoting.xtp">Resin remoting</a>.</td></tr><tr> <td>run-at</td> <td>Times to execute the servlet automatically.</td></tr><tr> <td>servlet-name</td> <td>The servlet's name (alias)</td></tr><tr> <td>servlet-class</td> <td>The servlet's class (In Resin, defaults to servlet-name)</td></tr></deftable><def title="<servlet> schema">element servlet { servlet-name < (servlet-class | jsp-file) < init* < init-param* < load-on-startup? < protocol? < run-as? < run-at?}</def><example title="Example: WEB-INF/resin-web.xml"><web-app xmlns="http://caucho.com/ns"> <servlet> <servlet-name>hello</servlet-name> <servlet-class>test.HelloWorld</servlet-class> <init-param> <param-name>title</param-name> <param-value>Hello, World</param-value> </init-param> </servlet> <!-- using Resin shortcut syntax --> <servlet servlet-name='cron' servlet-class='test.DailyChores'> <init-param title='Daily Chores'/> <load-on-startup/> <run-at>3:00</run-at> </servlet> <!-- mapping a url to use the servlet --> <servlet-mapping url-pattern='/hello.html' servlet-name='hello'/></web-app></example><p>Several <var>servlet</var> configurations might configure the sameservlet class with different <var>init-param</var> values. Each willhave a separate <var>servlet-name</var>.</p> <example title="Example: multiple servlets using the same class"><web-app xmlns="http://caucho.com/ns/resin"> <servlet servlet-name='foo-a'> <servlet-class>test.FooServlet</servlet-class> <init-param name='foo-a sample'/> </servlet> <servlet servlet-name='foo-b'> <servlet-class>test.FooServlet</servlet-class> <init-param name='foo-b sample'/> </servlet></web-app></example><p><var>load-on-startup</var> can specify an (optional) integervalue. If the value is 0 or greater, it indicates an order forservlets to be loaded, servlets with higher numbers get loadedafter servlets with lower numbers.</p> <p>There are a number of named servlets that are usuallyavailable to a Resin application, as defined in<var>$RESIN_HOME/conf/app-default.xml</var>.</p><example title="Example: servlet-mappings in $RESIN_HOME/conf/app-default.xml"> <servlet servlet-name="directory" servlet-class="com.caucho.servlets.DirectoryServlet"/> <servlet servlet-name="file" servlet-class="com.caucho.servlets.FileServlet"/> <servlet servlet-name="jsp" servlet-class="com.caucho.jsp.JspServlet"/> <servlet servlet-name="xtp" servlet-class="com.caucho.jsp.XtpServlet"/><servlet servlet-name="j_security_check" servlet-class="com.caucho.server.security.FormLoginServlet"/></example></defun><defun title="<servlet-mapping>" version="Servlet 2.2"><p>Maps url patterns to servlets. <var>servlet-mapping</var> has twochildren, <var>url-pattern</var> and <var>servlet-name</var>.<var>url-pattern</var> selects the urls which should execute the servlet.</p><deftable title="<servlet-mapping> Attributes"><tr> <th>Attribute</th> <th>Description</th></tr><tr> <td>init</td> <td><a href="resin-ioc.xtp">Resin-IoC</a> configuration of theservlet.</td></tr><tr> <td>protocol</td> <td>Defines the optional <a href="resin-remoting.xtp">remoting</a>protocol.</td></tr><tr> <td>servlet-class</td> <td>The servlet-mapping can define the servlet directly as a shortcut.</td></tr><tr> <td>servlet-name</td> <td>The servlet name</td></tr><tr> <td>url-pattern</td> <td>A pattern matching the url: <var>/foo/*</var>, <var>/foo</var>, or <var>*.foo</var></td></tr><tr> <td>url-regexp</td> <td>A regular expression matching the portion of the url that follows the <g>context path</g></td></tr></deftable><def title="<servlet-mapping> schema">element servlet-mapping { init? & protocol? & servlet-class? & servlet-name? < url-pattern* < url-regexp*}</def><example title="Example: WEB-INF/resin-web.xml <servlet-mapping>"><web-app xmlns="http://caucho.com/ns/resin"> <servlet> <servlet-name>hello</servlet-name> <servlet-class>test.HelloWorld</servlet-class> </servlet> <servlet-mapping> <url-pattern>/hello.html</servlet-class> <servlet-name>hello</servlet-class> </servlet-mapping> <!-- resin shortcut syntax --> <servlet-mapping url-pattern='*.xtp' servlet-name='com.caucho.jsp.XtpServlet'/></web-app></example><p><code>url-regexp</code> matches the portion of the url that follows the <g>context path</g>. A webapp in <code>webapps/ROOT</code>, and a url<code>http://localhost/foo/hello.html</code> will have a value of <code>"/foo/hello.html"</code> for thepurposes of the regular expression match.A webapp in <code>webapps/baz</code> and a url<code>http://localhost/baz/hello.html</code> will have a url of <code>"/hello.html"</code> for thepurposes of the regular expression match, because "/baz" is the context path.</p><p>In Resin, the special <code>servlet-name</code> <var>'invoker'</var> is used to dispatchservlets by class name.</p><warn>Enabling the <var>invoker</var> servlet cancreate a security hole in your application. Any servlet in theclasspath, perhaps even one in a .jar that you are unaware of,could be invoked.</warn><example title="Example: WEB-INF/resin-web.xml servlet invoker"><web-app xmlns="http://caucho.com/ns/resin"> <!-- used with urls like http://localhost:8080/servlets/test.HelloServlet --> <servlet-mapping url-pattern="/servlet/*" servlet-name="invoker"/></web-app></example><p>There are a number of mappings to servlets that are usuallyavailable to a Resin application, as defined in<var>$RESIN_HOME/conf/app-default.xml</var>.</p><example title="Example: servlet-mappings in $RESIN_HOME/conf/app-default.xml"><cluster><web-app-default> <servlet-mapping url-pattern="*.jsp" servlet-name="jsp"/> <servlet-mapping url-pattern="*.xtp" servlet-name="xtp"/> <servlet-mapping url-pattern="/servlet/*" servlet-name="invoker"/> <servlet-mapping url-pattern="/" servlet-name="file"/></web-app-default></cluster></example><p>The plugins use servlet-mapping to decide which URLs to send to Resin.The following servlet-name values are used by the plugins:</p><deftable title="servlet-name values used by plugins"><tr> <th>Attribute</th> <th>Description</th></tr><tr> <td>plugin_match</td> <td>The plugin will send the request to Resin, butResin will ignore the entry. Use to get around regexp limitations. (Resin 1.2.2)</td></tr><tr> <td>plugin_ignore</td> <td>The plugin will ignore the request. Use thisto define a sub-url the web server should handle, not Resin. (Resin 1.2.2)</td></tr></deftable></defun><defun title="<servlet-regexp>" version="Resin 3.0" type="defun"><p>Maps URL by regular expressions to custom servlets.</p><def title="<servlet-regexp> schema">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -