|
Resin usage profile
开发 When developing a JavaWeb project using Resin, you need to build your own WebApp. The development and use of ResinCmp / Ejb is not introduced here, only the application
Resin develops common jsp\javaservlet project. Here also talk about the configuration of resin.conf. There are two ways to apply in Resin
Release: First, release in Resin's directory; second, package into War release.
1, published in Resin's directory
查找 Find the <web-app> tag in resin.conf, this tag represents a web application.
In the tag, the id attribute indicates the web path of the application. Such as <web-appid = '/ test'>, it means that the application should be used when accessing on the Web
Http: // hostname / test / to visit. The app-dir attribute indicates the actual path of the application. Such as
<App-dir> d:\resin\doc\test </ app-dir> means the application is under the d:\resin\doc\test directory. The default value is below the root and id
A directory with the same name. Resin can be configured with 3 types of error-page: 404 error is the file cannot find the error page; Exception violation page; cannot connect
Java engine page. They can be set like this separately.
404 file not found page
<Web-appid = '/ app1'> <error-pageerror-code = '404'location =' / file_not_found.jsp '/> </ web-app>
Exception page
<Web-appid = '/ foo'> <error-pageexception-type = 'java.lang.NullPointerException'location =' / nullpointer.jsp '/> </ web-app>
Can't connect to srunServlet engine error page
设置 The settings on this page are irrelevant to the application and belong to the server settings.
<Http-server> <error-pageexception-type = 'connection'location =' / missing_file.html '/> </ http-server>
Classpath settings
See the following statement:
<Classpathid = 'WEB-INF / classes'source =' WEB-INF / src'compile = 'true' />
The value of the id parameter indicates the storage path of the compiled class in the classpath; the value of the source parameter indicates the storage of java source code in the classpath
Path; the value in compile may be true or false, indicating whether Java source code is automatically compiled by Resin's srun. Classpath settings
Generally related to the use of javaBean or Servlet. The value of id indicates the root of the compiled package of javaBean, and the value of source indicates
根 JavaBean java source code stored in the root. Servlet is the same.
Servlet settings
See the following statement:
<servlet-mappingurl-pattern = '*. xtp'servlet-name =' xtp '/> <servlet-mappingurl-pattern =' *. jsp'servlet-name = 'jsp' /> <servlet-mappingurl-pattern = ' / servlet / * 'servlet-name =' invoker '/>
Generally is to specify those that need to be parsed by srun. For example, here, change * .jsp to * .jss, the others remain unchanged, then as long as you encounter
* .Jss files are treated the same as the original * .jsp. Through this you can specify the engine for parsing, such as the following configuration:
<Servlet-mappingurl-pattern = '*. Xtp'servlet-name =' com.caucho.jsp.XtpServlet '/>
In servlet, you can also specify servlet. Such as
<Servletservlet-name = 'hello'servlet-class =' test.HelloWorld '/> <servlet-mappingurl-pattern =' / hello.html'servlet-name = 'hello' />
有 There is an important parameter case-sensitive in servlet-mapping. If it is on windows, it is best to configure it as false, ignore the case, from
But the agreement with windows.
Session configuration
See the following configuration statement:
<session-config> <session-max> 4096 </ session-max> <session-timeout> 30 </ session-timeout> <enable-cookies> true </ enable-cookies> <enable-url-rewriting> true < / enable-url-rewriting> <file-store> WEB-INF / sessions </ file-store> </ session-config>
Session-max: the maximum number of sessions session-timeout: the session expiration time, in minutes.
Whether cookies are allowed: refers to whether cookies are used in the session. If cookies are used, the browser must support session to use.
It is recommended to change to false when you do this. enable-url-rewriting and enable-cookies are generally used together. If enable-cookies is false,
Enable-url-rewriting should be set to true.
File-store: This configuration indicates whether the server stores the session as a file on the server. If you comment this out, then in your
序列 The WEB-Inf / sessions directory under the web-app directory does not store the serialized session object. Session also has jdbc-store configuration, corresponding
I saved the session permanently in the database through jdbc. In fact, it is the physical implementation of saving and reloading the serialized session variables. The session also supports the setting of multiple servers.
Set by tcp-store parameter. Because it involves the problem of load balancing, it will not be described in detail here, but simply write an example:
<Http-server>
<Httpid = 'a'port = '80' /> <srunid = 'a'host =' host-a'port = '6802' />
<Httpid = 'b'port = '80' /> <srunid = 'b'host =' host-b'port = '6802' />
Host <hostid = ``> <web-appid = ''>
<Session-config> <tcp-store /> <always-load-session /> </ session-config> </ web-app> </ host>
</ Http-server>
This example indicates that the session is passed in tcpring mode.
Temp-dir settings
Temp-dir refers to the temporary directory of the application. This is the directory used in javax.servlet.context.tempdir. Model recognition is the application directory
Your WEB-INF\tmp directory.
The above settings can be set in the <web-app> tag pair to control the settings of a web application.
2, packaged into War release
Here is how to publish the JavaWeb application that has been packaged into War under resin.
In fact, this is the simplest and clearest good method. In j2ee, all projects are packaged as ear releases. Among them, Web applications are packaged into
War, the ejb application is packaged into a jar. In resin, these can be deployed directly. Here I only introduce the deployment of Web applications packaged as war.
In resin.conf, look for this: <war-dirid = 'webapps' />. He said the path where the war file should be copied. This refers to relative
Based on the installation path of resin, the above setting means d:\resin\webapps. Just restart Resin. Resin will take the war from
Unpack it to the webapps directory. You can see something like this in the command console or stdout.log
[2002-04-2709: 56: 21.680] statement of initializingapplicationhttp: // haitaiserver: 8080 / rwtest. This one
Indicates that the web application is installed automatically. As long as this application is a j2ee-compliant web application, there should be no problems. Through the road shown above
You can access this application through the path. If you browse to d:\resin\webapps\rwtest, you will see that Resin has generated rwtest for you
Directory, below are META-INF and WEB-INF and your own JSP\servlet file and directory. It is fully consistent with the structure of j2ee. You can
建立 Create a new jsp\servlet in the rwtest directory, which can also be compiled and parsed and run. In practice, you can use Jbuilder
Or Ide tools such as WebSphere for integrated debugging and packaging are very convenient. |
|