📄 basic-config.xtp
字号:
<s1 title="Basic Configuration"><p>Because the flexibility of Resin's configuration can be overwhelming, we'vecollected the most important configuration here. Once you understand thebasic configuration, you can use it as a framework to attach more detailedconfiguration as you need it.</p><p>You may want to look at:</p><ul><li><a href="../java_tut/conf-basic.xtp">basic configuration</a> in thetutorial section.<li>System-specific <a href='starting.xtp'>installation</a> information is ina different section.<li>An <a href='config-index.xtp'>index</a> of all configuration elements.</ul><s2 title='Configuration Overview'><p>Configuring Resin involves configuring the following:</p><ul><li>ports and protocols: <a href="http-config.xtp#http">http</a>, ssl, <a href="http-config.xtp#srun">srun</a><li>resources (<a href="jndi.xtp">JNDI</a>): <a href="db-config.xtp">databases</a>, <a href="jms.xtp">JMS</a>, EJB, JNDI links<li>virtual hosts and web-applications<li><a href="app-config.xtp#classpath">classpaths</a><li><a href="servlet.xtp">servlets</a>: web.xml</ul><p>Resin organizes classes and JNDI resources into a tree.Each node in the tree inherits classes and JNDI resources fromits parents and adds it's own classes and resources. So a database<var/jdbc/test/> configured for the <var/foo.com/> virtual host wouldbe available for every web-app in the host.</p><figure src="jndi_tree.gif"/></s2><s2 title='Complete resin.conf Example'><p>The following creates a basic working configuration for a Resin standaloneconfiguration. Resin will compile and load servlets and classes placedin <var//home/ferg/public_html/WEB-INF/classes/> and jars placed inin <var//home/ferg/public_html/WEB-INF/lib/>.</p><p>The url <var//servlet/test.MyServlet/> will invoke a servlet in <var//home/ferg/public_html/WEB-INF/classes/test/MyServlet.class/>.</p><p>The url <var//hello.jsp/> will run a JSP in<var//home/ferg/public_html/hello.jsp/>.</p><example title="Example resin.conf"><caucho.com><http-server><http port='8080'/><host id=''> <doc-dir>/home/ferg/public_html</doc-dir> <war-dir>webapps</war-dir> <web-app id='/'> </web-app></host></http-server></caucho.com></example><p>Servlet configuration normally belongs in the web.xml in the WEB-INFdirectory. Resin-specific configuration, e.g. database configuration,belongs in a resin-web.xml file in WEB-INF or in the resin.conf.</p><p>Because Resin merges the contents of resin-web.xml, web.xml, and resin.conf,so you can put everything in the resin.conf if that makes your applicationeasier to maintain.</p><p>The following web.xml configures the special "invoker" servlet, which letsyou call servlets using the classname in the URL like/servlet/qa.MyServlet. In general, it's a better idea to create specificservlet-mappings for each servlet for better security.</p><example title="Example /WEB-INF/web.xml"><web-app> <servlet-mapping> <url-pattern>/servlet/*</url-pattern> <servlet-name>invoker</servlet-name> </servlet-mapping></web-app></example></s2><objsummary/><s2 title='http configuration'><defun title='caucho.com'><p>caucho.com is just a container for any Caucho configuration</p></defun><defun title='http-server'><p><a href='http-config.xtp'>http-server</a> contains allconfiguration for the Resin server.</p><p>The most important configuration variable is <var/app-dir/>.<var/app-dir/> configures the document root. <var/app-dir/> can appearin <var/<http-server>/>, <var/<host>/>, and <var/<web-app>/>.If it's not specified, it defaults to the parent.</p><example title='Apache Config'><caucho.com><http-server><app-dir>/usr/local/apache/htdocs</app-dir> ...</http-server></caucho.com></example><example title='IIS Config'><caucho.com><http-server><app-dir>d:\inetpub\wwwroot</app-dir> ...</http-server></caucho.com></example><example title='Resin Config'><caucho.com><http-server><app-dir>doc</app-dir> ...</http-server></caucho.com></example></defun><defun title='http'><p>Configures the HTTP port for Resin to listen at.</p><deftable><tr><th>Attribute<th>Meaning<td>Default<tr><td>port<td>TCP post to listen to<td>required<tr><td>host<td>TCP interface to listen to<td>all interfaces</deftable><example><caucho.com><http-server> <http host='localhost' port='6802'/> ...</http-server></caucho.com></example></defun><defun title='srun'><p>Configures a servlet runner port for Resin to listen at.</p><deftable><tr><th>Attribute<th>Meaning<td>Default<tr><td>port<td>TCP post to listen to<td>required<tr><td>host<td>TCP interface to listen to<td>all interfaces</deftable><example><caucho.com><http-server> <srun host='localhost' port='6802'/> ...</http-server></caucho.com></example></defun><defun title='host'><p>Each http-server contains some<a href='virtual-host.xtp'>virtual hosts</a>. Mostconfigurations will use the default host.</p><example><caucho.com><http-server><host id=''> ...</host></http-server></caucho.com></example></defun><defun title='web-app'><p>Each host contains some <a href='app-config.xtp'>webapplications.</a> A web application is just a container forsome servlets. It's closely related to thejavax.servlet.ServletContext.Most configurations will use the default web-app.</p><example><caucho.com><http-server><host id=''><web-app id='/'>...</web-app></host></http-server></caucho.com></example></defun></s2><s2 title='Servlets'><defun title='servlet-mapping'><p>Maps url patterns to servlets. <code/servlet-mapping/> has twochildren, <var/url-pattern/> and <code/servlet-name/>.<var/url-pattern/> selects the urls which should execute the servlet.</p><p>The special <code/servlet-name/> <em/invoker/> is used to dispatchservlets by class name. For example, /servlets/test.HelloServlet.<deftable title='url-patterns'><tr><td>/path/to/servlet<td>Exact URL match<tr><td>/prefix/*<td>Matching everything with a prefix<tr><td>*.jsp<td>Matching everything with an extension<tr><td>/<td>Replace the default servlet</deftable><p>In the following example, the URL <var//hello-world/> invokes the servlet</p><example><web-app id='/'><servlet> <servlet-name>hello</servlet-name> <servlet-class>test.HelloWorld</servlet-class></servlet><servlet-mapping> <url-pattern>/hello-world</url-pattern> <servlet-name>hello</servlet-name></servlet-mapping><servlet-mapping> <url-pattern>*.xtp</url-pattern> <servlet-name>com.caucho.jsp.XtpServlet</servlet-name></servlet-mapping></web-app></example></defun><defun title='servlet'><p>Defines a servlet alias for later mapping. More details are in the<a href='servlet-config.xtp'>servlet configuration</a> section.</p><deftable><tr><td>servlet-name<td>The servlet's name (alias)<tr><td>servlet-class<td>The servlet's class (defaults to servlet-name)<tr><td>init-param<td>Initialization parameters</deftable><p>In the following example, the url <var//hello.xtp/> invokes theservlet <var/test.HelloWorld/>. The servlet will use getInitParameter("title") to get the string "Hello, World".</p><example><web-app id='/'><servlet-mapping> <url-pattern>/hello.xtp</url-pattern> <servlet-name>hello</servlet-name></servlet-mapping><servlet> <servlet-name>hello</servlet-name> <servlet-class>test.HelloWorld</servlet-class> <init-param title='Hello, World'/></servlet></web-app></example></defun></s2><s2 title='Formal Description'><p>The following description condenses the full<a href='config-sum.xtp'>configuration summary</a>.</p><def>caucho.com ::= <a href='http-config.xtp#http-server'>http-server</a> <a href='http-config.xtp'>http-server</a> ::= <a href='http-config.xtp#http'>http</a>* | <a href='http-config.xtp#srun'>srun</a>* | <a href='http-config.xtp#host'>host</a>*<a href='http-config.xtp#host'>host</a> ::= <a href='http-config.xtp#war-dir'>war-dir</a> | <a href='app-config.xtp#web-app'>web-app</a>*<a href='app-config.xtp#web-app'>web-app</a> ::= <a href='app-config.xtp#servlet-mapping'>servlet-mapping</a>* | <a href='app-config.xtp#servlet'>servlet</a>*<a href='servlet-config.xtp#servlet'>servlet</a> ::= <a href='servlet-config.xtp#servlet-name'>servlet-name</a> | <a href='servlet-config.xtp#servlet-class'>servlet-class</a> | <a href='servlet-config.xtp#init-param'>init-param</a>*<a href='app-config.xtp#servlet-mapping'>servlet-mapping</a> ::= <a href='app-config.xtp#url-pattern'>url-pattern</a> | <a href='servlet-config.xtp#servlet-name'>servlet-name</a></def></s2></s1>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -