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 used very convenient, which is very small, suitable for development constant debugging; you can also integrate use with JBuilder integrated development tools. 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 perspective of use, individuals think that RESIN is convenient than Tomcat, and RESIN can also be used in conjunction with JBuilder6. RESIN emphasizes the use of XML technology, you can see from RESIN own HomePage. Second, RESIN installation and configuration resin can be downloaded and used free in http://www.caucho.com/download/index.xtp. Using RESIN development or learning is free of charge, but if resin is released as a charging 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. Su: Resin 2.0.4 (Built THU NOV 15 17:56:24 PST 2001) COPYRIGHT (C) 1998-2001 Caucho Technology (CAUCHNOLOGY) All Rights Reserved. Starting Resin on WED, 23 Jan 2002 14:41:47 0800 (CST HTTP Listening to *: 80 SRun Listening to Haitaiserver: 6802 Points STOP, you can stop the current RESIN server process; choose 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: . Configuration in the http-server> tag is related to the RESIN's Java web server. Find , in the app-dir> 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 an HTTP server. This will be mentioned in the following paragraphs. Find the 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: Esindoc (assuming your appdir> the 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.
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 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: esindoc EST app-dir> indicates that the app is in 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 is not found to find the page web-app> exception illegal page web-app> Unable to connect to the SRun Servlet Engine Error page Settings And application is independent, belonging to the server settings. http-server> ClassPath settings See the statement below: ID parameter represents the storage path of compiled Class in classpath; the value of the Source parameter represents the storage path of the Java source code in the classpath; the value in Compile May be true or false, indicating whether the Java source code is automatically compiled by the SRUN of Resin. 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 settings See the statement below: generally specifies that those 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. By this can specify the parsed engine, as follows: In Servlet, you can specify a servlet. Such as in servlet-maping An important parameter, 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: 4096 session-max> 30 true enable-cookies> True enable-url-shutriting> Web-inf / sessions file-store> session-config> session-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 write an example: session-config> web-app> host> http- Server> This example indicates that the session is passed in a way 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 tag 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 put the WAR self-enclosure to 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: esinwebapps wart, you will see that resin has generated the rwtest directory for you. Here is Meta-INF and Web-INF and 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 open the 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 start of any JSP file is increased: <% @Page ContentType = "text / html; charset = GB2312"%> Chinese issues is 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 = " table>
". getBytes ("GB2312"); _Jsp_String27 = " td>
tr>
".getbytes (" GB2312 "); above is the displayed encoding of the page. Among them, getBytes ("GB2312") is a static code, which is set 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 in-error = 'true' /> 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 tolerate GB2312. According to the method of solving the multi-language language, use ISO-8859-1 on the pure English platform to process internal encoding, and the display of the display push the character's machine. So this is as long as the code is correct, there is no problem in the page on the page. Tomcat3.2 is inconvenient is Tomcat's operation in the database of the database. It is necessary 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 go: 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 JBuilder6 Esin-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 the initial installation. Resin supports the database buffer pool. Here, it provides dbpool to package the buffer pool. When actually use, just configure this in resin.conf: orcl id> oracle.jdbc.driver.Oracledriver driver> jdbc: Oracle: Thin: @localhost : 1521: SMTH URL> jdbc: Oracle: OCI8: @smth url> -> scott user> Tiger password> 5 max-connections> then, you can use this in your JSP or servlet: first import com.caucho.sql. * Pack, then get the connection directly: Connection conn = DBPool.getPool ("ORCL"). GetConnection (); Personal recommendation Do not use the connecting pool as above, or by using the EJB method with the DataSource object found directly from the Context to get the connection versatility.