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:
Find
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
In the label, the id attribute indicates the web path of the application. Such as
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:
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
Squiion configuration
See the following configuration statement:
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:
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
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:
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
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:
jdbc: Oracle: OCI8: @smth url> ->
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.
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.