RESIN server

xiaoxiao2021-03-05  29

First, Java Web Server Selection Introduction

When the Java Web project is actually implemented, the business Java web server we can use has IBM WebSphere, BEA Web Logic. These two servers are complete and powerful, support all Java service container standards, suitable for the release of the finished business Java web application. But these two servers are commercial servers, which is expensive, and it is extremely high for system resources. Especially the WebSphere configuration is complex, and if it does not match IBM WebSphere Studio Application is very uncomfortable. And their different versions are different from JavaX components such as servlet.jar and JDK. Servlet.jar requested by WebSphere 3.5 supports the old version of Javax.Servlet.http.httpSession, does not support session.settribute () session.getaTRibute ().

During development or learning, there are many free light Java web servers for us to choose, such as Tomcat, Resin, Orion, etc. They are very convenient, which is very small, suitable for development constant debugging; you can also use integrated development tools such as JBuilder. According to the situation in actual development, Jakata Tomcat and Sun Java combine the best, and other application servers can support complete J2EE standards, and applications are also wide. But from the universal coding problem in Java, it is still the best in resin. There is also a way of use, individuals think that RESIN is convenient than Tomcat, and RESIN can also use IDE such as JBuilder6. RESIN emphasizes the use of XML technology, it can be seen from RESIN own HomePage to use XTP.

Second, RESIN installation and configuration

         / l l. 下载 下载 下载 下载 下载 下载 免费 免费 免费 免费 免费 免费 免费 免费 免费 免费 免费 免费. 免费...... Using resin is developed or learned to be free, but if resin is released as a charge product is required. The current version is 2.10.

Local download:     = 26 resin 2.javafan.net/softview.javaffan.net/softview.javafan.net/softview.jAVAFAN.NET/SOFTVIEW.JSP? ID = 159 RESIN 3.0. 8

Select the normal installation package of Windows.zip in Archive Versions when downloading resin. RESIN-2.1.0.zip.

This zip is poured down to any directory, such as d: / resin. The following introductions are assumed that RESIN is installed under D: / RESIN. Enter D: / Resin / BIN, type HTTPD, you can run the RESIN server under the command line console. At this point, a dialog box with Start and STOP pressing two Radio pressing the New and a Close press New. Here you can see the operation information of RESIN. This information is also seen in the stdout.log log file below the D: / Resin / Log directory. Such as:

Resin 2.0.4 (built Thu Nov 15 17:56:24 PST 2001) Copyright (c) 1998-2001 Caucho Technology. All rights reserved.Starting Resin on Wed, 23 Jan 2002 14:41:47 0800 (CST)

      zrun listening to haitaiserver: 6802

Click STOP to stop the current RESIN server process; then click Start and open the new RESIN server process. Turning the dialog box, go back to the COMMAND console. If in the NT4 or Win2K environment, you need to treat resin as a service, just need to type httpd? Install in this directory of the Command Console, you can see the new RESIN Web Server's automatic service. You can start the RESIN service as long as you enter NT 4 or Win2K. This service can also be set to manually or disabled like other services. Note Sometimes after installing the service, starting Resin, does not see what you write about the RESIN routine can be parsed, and the browser displays the server can't find an error. This issue can be solved as long as Win2K or NT is restarted. The following is a brief introduction to the configuration of the RESIN server. Like most Java web servers, the RESIN server is configured via an XML file.

Enter the D: / Resin / Conf directory, open resin.conf, which is a text in XML format. There are a lot of tags in this, first check: . Configuration in the tag is related to the RESIN's Java web server. Find , in the tag pair, the root of RESIN, equivalent to the HTDOCS or IIS of Apache. Resin comes with an HTTP server, but it can also be used without using Apache or IIS to do HTTP servers. This will be mentioned in the following paragraphs.

Find tag, which can configure . The Host parameter specifies the server, the port specifies the HTTP port, which is the LocalHost and 8080 by default. There is also tag. This is the engine configuration of JSP and Java Servlet. Generally, it is possible, unless the 6802 port has been occupied by other programs. Then, configure the JDK. This needs to be set in ClassPath. Right click on my computer, in the advanced tab of system features, click on the environment variable, create a new environment variable in the system variable, the variable is called classpath, the value of the value is the directory where the value is a new environment variable, the variable is called PATH The value is the directory where javaac.exe and java.exe (in the bin directory below the directory where JDK). Generally, this will be used after this. In D: / Resin / DOC (assuming your name is DOC, that is, the root is d: / resin / doc, and your such as left configuration), write a JSP file, if you can write a Test.jsp file, the content is <% = 1 2 3%>. Then, in the browser, type http: //localhost/test.jsp. If you can see the browser display 6, the RESIN server is already running normally. Note that after modifying the configuration, it is generally restarted to see the change. 3. Introduction to RESIN

When using the RESIN to develop Java Web project, you need to build your own webApp. It does not introduce the development and use of Resin CMP / EJB, only describe the Undon JSP / Java Servlet project with RESIN. Here you still have to talk about the configuration of Resin.conf. Applications in Resin can be released in 2 ways: First, publish in the directory of resin; second, packing into a WAR release.

                            

Find the tag in resin.conf, which represents a web application.

In the label, the id attribute indicates the web path of the application. Such as indicates that the application should be accessed with http: // hostname / test / to access when accessible on the web. The App-Dir property indicates the actual path of the application. Such as d: / resin / doc / test indicates that the app is under the D: / Resin / Doc / Test directory. The default is the directory of the same name below the root. Resin can configure 3 Error-Page: 404 Errors is that files cannot be found; Exception violation page; cannot connect to the Java engine page. They can set this with this.

404 file can't be found

                                                                                                                    

Can't connect to the SRun Servlet engine error page

This page settings and applications are independent of the server settings.

Classpath setting

See the following statement:

                                                                   Source code. The set of ClassPath is generally related to the use of JavaBean or servlet. The value of the ID represents the compiled package of JavaBean, and the value of the source represents the root of JavaBean's Java source code. The same is available in servlet.

Servlet setting

See the following statement:

  = '*. Jsp' servlet-name = 'JSP' />  

General is to specify those who need to pass SRUN. For example, here, change * .jsp to * .jss, other unchanged, then as long as you encounter * .jss files when you visit * .jsp, you will be processed like * .jsp. By this can specify the parsed engine, as follows:

In servlet, you can also specify a servlet. Such as

  There is an important parameter in servlet-mapping.

Squiion configuration

See the following configuration statement:

4096 30 True     True Web-inf / sessions

Squsion-Max: The largest session number   quassion-timeout: session expired time, in minutes. Whether to allow cookie: refers to whether the session uses cookies. If you use cookies, the browser must support Session to use, and it is recommended to change to false when publishing. Enable-url-rebriting and enable-cookies are generally used. If enable-cookies are false,   an anenable-url-rebriting should be set to TRUE is appropriate. File-Store: This configuration indicates whether the server stores the session as a file on the server. If this item comes out, the web-INF / sessions directory under your web-app directory does not save the serialized session object. Session also has a JDBC-Store configuration, which corresponds to the Session in the database through JDBC. In fact, it is the sequential preservation and reloading physical implementation after session variables.

Here SESSION also supports multi-server settings, with TCP-Store parameter settings. Due to the problem involving load balancing, it will not be described in detail here, only simply writing an example:

/ http-server>

This example indicates that the session is passed in a manner in TCP Ring.

Temp-Dir setting

Temp-DIR refers to the application's temporary directory. That is, the directory used in javax.servlet.context.Tempdir. Acknowledge is the web-inf / tmp directory in the application directory.

The above settings can be set in the tag pair, control the settings for a web application.

2, packaged into a WAR release

The following is an introduction to how to use the Java web app that has been packaged into a WAR in RESIN.

In fact, this is the simplest and clearest way. In J2EE, all items are packaged into EAR release. Among them, the web application is packaged into a WAR, EJB application is packaged into JAR. In RESIN, these can be deployed directly. Here I only introduced the deployment of the web application that is packaged into a WAR.

In Resin.conf, look for this: . He said that the WAR file should be copied by copy. Here, it refers to the installation path relative to RESIN, as described above represents D: / Resin / WebApps. Just restart RESIN. RESIN will automatically unpack the WAR into the webapps directory. You can see the statement similar to [2002-04-27 09: 56: 21.680] Initializing Application http: // haitaiserver: 8080 / rwtest.log in the Command Console or Stdout.log This means that the web application is automatically installed. As long as this application is a web application that meets the J2EE standard, there should be no problem. This application can be accessed by the path displayed above. If you visit D: / Resin / WebAPPS / RWTest, you will see that Resin has generated the rwtest directory for you, below Meta-Inf and Web-INF have your own JSP / servlet files and directories. It is the structure that is fully compliant with J2EE. You can build a new JSP / servlet in the rwtest directory, which can be compiled and resolved and run. In actual operation, you can use JBuilder or WebSphere to make integrated debugging and packaging, very convenient.

  four, using RESIN for the development and debugging of Java web projects

  Here are limited, it is impossible to talk too much, I only introduce the most useful part of the actual.

If the error page is defined, the most common large string Exception will not be seen after an error, and directly jump to the error page. So it is recommended to develop a wrong page first. The most common in jsp errors is NullPoint Exception, followed by the name of the name. Error can also be found in stderr.log under the log directory in the resin installation directory. Many useful error messages can be seen by analyzing the log file.

When debugging JSP, if a compile is true, the JSP is first translated into a servlet's Java file, and then compiled into a Class file. You can find this file in your own work directory. The name of Java is in this, which is the case defined in this: The original JSP file name is before adding the line, plus _Jsp this word. So the name in the Java application should not end with _JSP, and do not have Chinese names and other characters; in fact, the name is not legal as the beginning of _JSP.

  Java supports the support of multi-language language, and it has been solved in RESIN. Take JSP as an example, refer to the Java servlet file generated by RESIN. As long as the origination of any JSP file is increased: <% @Page ContentType = "text / html; charset = GB2312"%>

Chinese issues are solved. Check the generated servlet source file:

ponse.setContentType ("text / html; charset = GB2312"); REQUEST.SETCHARACTERENCODING ("GB2312");

The above is set the character set

Private static byte [] _jsp_string26 ;private static byte [] _Jsp_string27;

                                                     ;.                                ==============================================10 .GetBytes ("GB2312");

The above is the encoding of the display of the page. Among them, getBytes ("GB2312") is a static code, which is RESIN to set up in order to solve some environments or not normal display. In Resin's configuration file (/conf/Resin.conf), you can set the static-encoding property in to the static-encoding property in ". TRUE or FALSE to control whether static coding is static. In fact, in the inside of the RESIN container, all characters are processed in accordance with ISO-8859-1. ISO-8859-1 is a large character set, although Chinese GB2312 and 8859 have different definitions in words, but encoding is inclusive of GB2312. According to the method of solving the multi-language language, use ISO-8859-1 on the pure English platform to process the internal encoding, and the display of the display is pushed to the client's machine. So just as long as the coding is correct, there is no problem in the page displayed on the page. Tomcat3.2 is inconvenient to Tomcat's operation Chinese support for the database, you need to manually encode the Java Bean or Servlet. By testing, there is no such problem in RESIN. Tomcat4.0 solves this problem. However, personal habits still feel that RESIN is convenient in configuration.

The introduced JAR can be automatically solved in RESIN. This is very useful in the development kits provided by a special class or a third party. Method is very simple: Just copy the jar or zip to the LIB directory under the RESIN installation directory, restart RESIN, you can. If the db2java.zip file used in DB2, it is possible to copy to D: / resin / lib as long as it is easy.

Esin provides an integrated debugging of JBuilder. You can download: http://www.caucho.com/projects/jbuilder/resin-jbuilder.jar downloads to RESIN's JBuilder IDE extension. Then, the package is called: resin-jbuilder.jar, copy it to the jbuilder6 / lib / ext directory. Then, install the resin2.1 unpacking in the JBuilder6 / Resin-2.1 directory, you can. Open any WAR project, right click on Project, select Properties, select the Servers tab. On the original selection box, you can see more resin2.1. This way can you debug JSP / servlet like Tomcat, and more convenient than Tomcat. Debug method and use Tomcat debugging. 5. Other issues

Use RESIN to be used in conjunction with Apache. That is to use Apache to do HTTP servers, and RESIN is a SRun server. You can refer to Apache.conf under the resin / conf / samples directory. Mainly to set App-DIR to / usr / local / apache / htdocs (which is Apache's root). At the same time, http.conf in Apache also made a corresponding setting. RESIN also provides automatic installation of the process, running resin / bin / setup, you can select Apache in the dialog box in the bomb, so you can. As long as you have installed Apache, RESIN can find the path where the httpd.conf file is located.

Use the command line to start RESIN, if resin.conf is changed, RESIN will restart the adaptation to the new configuration. This is very suitable for use in initial installation.

The support for the database buffer pool is very good. Here, it provides dbpool to package the buffer pool. When actually use, as long as it is configured in RESIN.CONF:

ORCL Oracle.jdbc.driver.Orcledriver JDBC: Oracle: Thin: @localhost: 1521: SMTH

jdbc: Oracle: OCI8: @smth ->

Scott Tiger

5

  then, in your JSP or servlet, you can use this:

First introduced the com.caucho.sql. * Package, then get the connection directly:

Connection conn = dbpool.getpool ("orcl"). GetConnection ();

  Personally do not use the connection pool as above, or in accordance with the EJB method with DataSource objects found directly from Context to the DataSource object. The code is also very simple:

Context ctx = new initialContext (); DataSource DS = (Datasource) CTX.lookup ("JDBC / EMPLOYEDB") ;Connection conn = ds.getConnection ();

The JDBC is configured in RESIN.

JDBC / EMPLOYEEDB javax.sql.datasource

  Developing RESIN Web Server is still relatively pleasant. Just provide an existing management console like WebLogic or WebSphere. But from stability and convenience, Resin individual thinks a lot more than Tomcat. Moreover, RESIN also provides RESIN-CMP and RESIN-EJB, which is more powerful.

转载请注明原文地址:https://www.9cbs.com/read-38429.html

New Post(0)