I. 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 (). In the development or learning process, there are many free light Java web servers for us to choose, such as Tomcat, Resin, Orion, and more. 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 resin can be downloaded and used free in http://www.caucho.com/download/index.xtp. 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. Select the normal installation package of Windows.zip in Archive Versions when downloading Resin. RESIN-2.1.0.zip. Pack the zip package to any directory, such as d: esin. The following introductions are assumed that RESIN is installed under D: ESIN. Enter D: Esinin, 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: EsinLog directory. Such as: RESIN 2.0.4 (Built THU NOV 15 17:56:24 PST 2001) CAUCHO TECHNOLOGY. All Rights Reserved.starting Rights Reserved.starting Resin on WED, 23 Jan 2002 14:41:47 0800 (CST HTTP Listening to *: 80Srun Listening to Haitaiserver: 6802 Points STOP, you can stop the current RESIN server process; select 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: esinconf directory, open resin.conf, which is a text in XML format. There are a lot of tags in this, first check:. The configuration in the mark is related to the Java web server of the RESIN. Found, in the mark pair, the root of RESIN, is equivalent to the HTDOCS or IIS of the 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 tags, it can be configured. The Host parameter specifies the server, the port specifies the HTTP port, which is the LocalHost and 8080 by default. There is also a marker. 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: Esindoc (assuming that your pair is DOC, that is, the root is D: / resin / doc, and your as left configuration), write a JSP file, if you can write a Test.jsp file, The content is. 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. Third, RESIN Use Introduction Use the RESIN to develop Java Web projects, you need to build your own webApp. It does not introduce the development and use of Resin CMP / EJB, only describes the use of RESIN to develop a normal JSPJAVA Servlet project. 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. 1. Release it in resin.conf in resin.conf, which represents a web application. In the label, the id attribute indicates the web path of the application. For example, it should be accessed with http: // hostname / test / to access when the application is accessed on the web. The App-Dir property indicates the actual path of the application. Such as D: Esindoc EST indicates that the application is below the D: Esindoc EST 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 Connect to the Srun Servlet Engine Error page This page settings and applications are not related to the server settings.
ClassPath's setting See the statement below: The value of the ID parameter represents the storage path of the compiled Class in the classpath; the value of the Source parameter represents the storage path of the Java source code in the classpath; the value in the Compile may be true or false, indicating whether Resin's SRUN automatically compiles Java 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. The set of servlets see the statement below: generally specifies those resolutions that need to pass through 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. Through this can specify the parsed engine, as follows: In the servlet, you can specify a servlet. If there is an important parameter in servlet-mapping Case-Sensitive If in Windows, it is best to configure to false, ignore the case, thus consistent with Windows. SESSION configuration See the following configuration statement: 409630 rutrueweB-INF / SessionSession-max: Maximum session number session-timeout: session expired time, in minutes. Whether to allow cookie: refers to whether SESSION is 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, enable-url-shutriting 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 the multi-server settings, and is set by TCP-Store parameter. Due to the problem involving load balancing, it will not be described in detail here, only simply writes an example: This example indicates that the session is passed in a manner in which it is described in TCP Ring. Temp-Dir setting TEMP-DIR refers to an application's temporary directory. That is, the directory used in javax.servlet.context.Tempdir. Acknowledges the web-inf mp directory in the application directory. The above settings can be set in the label pair, control the settings for a web application. 2. Packing into a WAR Release The following is the introduction to how to publish the Java web app that has been packaged into a WAR under 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 the RESIN, as described above represents D: ESINWEBAPPS. 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 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: EsinWebAppswtest, you will see that RESIN has generated a rwtest directory for you, below Meta-INF and Web-INF have your own JSPSERVLET files and directories. It is the structure that is fully compliant with J2EE. You can build a new JSPServlet 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. Fourth, using RESIN for the development of Java web projects and debugging here limited space, 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. Regarding Java support issues for multi-language, 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: Chinese issues are solved. Servlet view generated source files fragment: response.setContentType ( "text / html; charset = gb2312"); request.setCharacterEncoding "GB2312"); the character set of the above private static byte [] _jsp_string26; private static byte [] _jsp_string27; _jsp_string26 = "" ".getbytes (" GB2312 "); above is the displayed encoding 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 the configuration file (/conf/Resin.conf) in RESIN, you can control whether the static encoding is controlled by the static-encoding attribute in the setup. 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, you can easily copy to D: esinlib. Resin 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 jbuilder6libext directory. Then, install the resin2.1 unpack in the JBuilder6esin-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 can debug JSPSERVLET like Tomcat, and more convenient than Tomcat. Debug method and use Tomcat debugging. 5. Other issues can 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 resinconfsamples 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 program for this process, running resininsetup, you can choose 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. Start RESIN using the command line, if resin.conf is changed, RESIN will restart to adapt to the new configuration. This is very suitable for use in initial installation. Resin supports the database buffer pool. Here, it provides dbpool to package the buffer pool. When actually use, as long as RESIN.CONF is configured: Orcl Oracle.jdbc.driver.OracleDriverJDBC: Oracle: Thin: @localhost: 1521: Smthjdbc: Oracle: OCI8: @Smth -> Scotttiger5 then, in your JSP or servlet It can be used in this way: introduce the com.caucho.sql. * Pack, then get the connection directly: Connection conn = dbpool.getpool ("c"). GetConnection (); Personally Nelet Do not use the connection pool as above, or The connection versatility is better in the DataSource object found directly from Context according to the EJB method.