Win2000 Server + Java 2 (JDK1.4.0) + Apache1.3.23 + Tomcat-4.0.3

zhaozj2021-02-16  43

//// jsp Java Servlets Establishment and implementation of programming environment <1> /// / /// Win2000 Server Java 2 (JDK1.4.0) Apache1.3.23 Tomcat-4.0.3 WebApp-Module- 1.0 //// ////// //// author: josser chai (has now changed to Abner Tsai) //// address: abnertsai@sina.com or josserchai@yahoo.com //// 2002.3.7 ////:: // // I offer this file for only the use of learning, any individual and organization can be used. At the same time, if you find that there is a better, simpler method in the process of use, please ask for e-mail. Thank you! At the same time, please ask anyone when you turn the content of this document, please /// Keep this document statement. / // // / //////// / /// //// ///> in 2002.6.11, modify and add some content on this article, and the increased content is: /// How to set it yourself JSP and servlet directory and programs, and because there are many netizens to write to me, there is a mistake in the installation process ////, there is no implementation, because I work too busy, there are many netizens' believes, I haven't returned, please Forgive me. One / / / / must be done as much as possible. At the same time, the part of setting the ClassPath is set to make it more simple. // / / / / / / / / /: Note: There are various ways to configure JSP programming on the network, such as using Jserve Apache Tomcat, JSDK IIS, etc. But as a personal learning, I pushed Apache Tomcat. However, there are many ways to have many configurations on the network. Most of them are troublesome, such as using MOD_JK. And those methods are not applicable to the latest distribution software here (I tried, you can try, pay attention to the Windows series, if the Tomcat4.0 is combined, apache1.3.23 is the most stable version, Apache1 .3.6 or apache2.0 will have problems).

Java 2 (JDK1.4.0-B92) is the << Latest version >> Java compiler released by Sun. The download address is: www.sun.com/j2se/1.4/

Tomcat-4.0 is a web server that supports the latest JSP for Apache organizations. The download address is: http://jakarta.apache.org/builds/jakarta-tomcat/release/apache1.3.23-win32 is the Apache organization released the most stable web server that supports Window 98 / NT / 2000. The download address is: http://www.apache.org/dist/httpd/

WebApp-Module-1.0 is a support interface that Apache and Tomcat is better than Apache organization. The download address is: http://www.apache.org/dist/httpd/

Win2000 (Family) Server does not need to be explained. / / Oh, if you don't know, you don't look down.

Configuration method:

First, install Win2000, if you use it, this step can be.

Second, A: Download Java2 (JDK1.4.0), the downloaded file name is: J2SDK-1_4_0-win.exe. Double-click to run, press the default to install it to the C: /J2SDK1.4.0 directory. JRE will be automatically installed to C: / Program Files / Java / J2RE1.4.0, JRE is the necessary support environment that runs Java programs.

B: After installation, you need to set the path: The method is as follows: Click "My Computer" right-Property-Advanced - environment variable, the new "Java_Home" value in "System Variable" is: C: / J2SDK1. 4.0

Note: The row of the front belt // below is to choose one of the rows of //, that is, both only need to do one time. // New: ClassPath value is: //c:/j2sdk1.4.0 /LIB/dt.jar;c :/j2sdk1.4.0/lib/tools.jar;c:/j2sdk1.4.0/lib/htmlconverter.jar;c:/program files / apache tomcat 4.0 / common / lib / servlet.jar / / Note that you should write, use ";", " ; C: / program files / apache tomcat 4.0 / common / lib // Note To write, use ";" separation; // New: _Runjava, value is: c: /j2sdk1.4.0/bin/java // New: _Runjavaw, value: c: /j2sdk1.4.0/bin/javaw // New: _runjdb, value is: c: /j2sdk1.4.0/bin/jdb // The above variables built in compilation JSP and SERVLETS

Then, double-click the PATH variable here, add:; C: /J2SDK1.4.0/bin so that you can compile the Java file elsewhere.

C: Test JDK installation success: Built a Myjava directory in C: /J2SDK1.4.0, then copy C: /J2SDK1.4.0/Demo /Applets/clock to the case1.html to the Myjava directory, then Execute:> Javac Clock.java> AppletViewer Example1.html You can see a moving clock that pops up, indicating that the test applet is successful. Then Test the Java Application Use the following program to note the Note Test.java file, pay attention to the extension .java. Public class test {public static void main (string args []) {system.out.print ("Hello World, JDK SETUP SUCCESSFUL! / N");}} Put this Test.java file in the Myjava directory, then execute :> Javac Test.java> Java Test can see the "Hello World, JDK SETUP SUCCESSFUL!" Text, indicating that JDK is installed.

Third, A: Install Tomcat-4.0, downloaded the file name is: jakarta-tomcat-4.0.3.exe, run it directly and press it by its default directory to C: / Program Files / Apache Tomcat 4.0 below. B: Configure Tomcat Path: 1: Click "My Computer" right-Property - Advanced - environment variable, in "System Variable" New "Catalina_Home" value: c: / program files / apache tomcat 4.0 // 2 : Find the C: / Program files / apache tomcat 4.0 / bin / setclasspath.bat file, change all of these% basedir% // to% catalina_home% // and find the set classpath, change to: // set Classpath =% java_home% / lib / Tools.jar;% java_home% / lib / dt.jar;% java_home% / lib / htmlconverter.jar;% catalina_home% / common / lib / servlet.jar // setClassPath.bat file is Tomcat provides a batch file for setting library files, which can test whether your running environment // ClassPath is correct. Its content should be revised as follows: if not "% JAVA_HOME%" == "" goto gotJavaHomeecho The JAVA_HOME environment variable is not definedecho This environment variable is needed to run this programgoto end: gotJavaHomeif exist "% JAVA_HOME% / bin / java .exe "goto okJavaHomeecho The JAVA_HOME environment variable is not defined correctlyecho This environment variable is needed to run this programgoto end: okJavaHomeif not"% CATALINA_HOME% "==" "goto gotBasedirecho The CATALINA_HOME environment variable is not definedecho This environment variable is needed to run this programgoto end: gotBasedirif exist "% CATALINA_HOME% / bin / setclasspath.bat" goto okBasedirecho The CATALINA_HOME environment variable is not defined correctlyecho This environment variable is needed to run this programgoto end: okBasedirrem Set the default Java options for all scriptsset JAVA_OPTS = Rem set the default -djava.endorsed.dirs argumentset java_endorsed_dirs =% catalina_home% / bin;% catalina_home% / common / lib

rem Set standard CLASSPATHrem Note that there are no quotes as we do not want to introduce randomrem quotes into the CLASSPATHset CLASSPATH =% JAVA_HOME% / lib / tools.jar;% JAVA_HOME% / lib / dt.jar;% JAVA_HOME% / lib / htmlconverter.jar;% CATALINA_HOME% / common / lib / servlet.jarrem Set standard command for invoking Java.rem Note that NT requires a window name argument when using start.rem Also note the quoting as JAVA_HOME may contain spaces.set _RUNJAVA = " % Java_home% / bin / java "set _Runjavaw ="% java_home% / bin / javaw "set _runjdb =" java_home% / bin / jdb ": End // If you have a little understanding of the batch file, you can easily see Understand the code above.

Note: The top of the top with //, the row with the top of the top, select one, that is, the two can only be done once. C: Configure Tomcat configuration file, in C: / Program Files / Apache In Tomcat 4.0 / conf / server.xml, you are not configured, if you want to configure it, you can match it below. D: Test Tomcat Installation Success: Open IE, type in the address bar: http: // localhost: 8080 You can see Tomcat's page. Or enter http://xxx.xxx.xx.xxx:8080 where xxx.xxx.xx.xxx is your Win2000's IP address. E: How to configure Tomcat to run your own JSP file and Java servlet, will explain the following: 1: Configure the Tomcat's server.xml file to support your JSP file. Use Notepad to open the server.xml file below Conf, find it: ............! - Tomcat root context -> ->

........... A few lines. Then add the following lines in the "DocBase =" root "debug =" 0 "/> ->" above: This is a directory MYJSP that puts its own JSP file in the root directory below the WebApps directory (Tomcat's default page directory). Of course, before doing the above steps, you must first build an empty myjsp directory in the root directory. If you want to add a few JSP directories, you can add it to the same aspect. 2: Test your own JSP files in the Myjsp directory, build a file name: helloWorld.jsp, use Notepad Editing to make its content as:

<% = msg%> saved file, boots Tomcat server, then in the browser Enter http: //xx.xxx.xxx.xx: 8080 / myjsp / helloWorld.jsp can see the output. Or enter http: //xxx.xxx.xxx.xx: 8080 / myJSP / you can browse the directory, then click the file. Note xxx.xxx.xxx.xx is your IP address, or LocalHost. Note: The file name is the case.

3: Sets the Tomcat to run your own servlet to build a class content in the web-inf directory below the root, then use Notepad to open the Web.xml of the web-inf directory in the ROOT in the Increase content between , make it a web.xml content as shown below: Hello this servlet plays the" Hello World Example "role. Just A Hello World Program! Hello 5 Hello *. do 30 Web.xml is the easiest declaration for servlet, which declares a servlet called Hello, use it We test. hello *. Do The declaration is available in servletname.do in the browser to browse this servlet with localhost: 8080 / hello.do. The * .do here is arbitrary, or may be set to * .pl and so on.

You can also use the hello * to use the servlet name to browse the servlet Here, Localhost: 8080 / Hello can also use Hello / servlet / * For replacement, this time is to use the path name and servlet name to browse the servlet, which is localhost: 8080 / servlet / hello 4: Test your own servlet, built a named hello.java file, input it follows: import java.io *; import javax.servlet *; import javax.servlet.http *; public class hello extends HttpServlet {public void init (ServletConfig config) throws ServletException {super.... init (config);} public void destroy () {super.destroy ();} public void service (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {resp.setContentType ( "text / html"); PrintWriter out = new PrintWriter (Resp.getOutputStream ()); out.println (""); out.println (" HelloWorldexample </ title> </ head>); OU T.Println ("<body>"); out.println ("Hello! This is my first servlet program!"); out.println ("</ body>"); Out.println ("</ html>" Out.close ();}} then go to DOS, enter the classes directory, run:> Javac Hello.java</p> <p>You can see a hello.class file in the class directory. If you have a problem with compilation here, check whether you set up the ClassPath and PATH. Then enter http: //xxx.xxx.xxx.xx: 8080 / hello.do to see the result of the servlet run in the browser. Where xxx.xxx.xx.xxx is your IP address. To this, you have configured your JSP and servlet running environment. Let's talk about how to join the Apache.</p> <p>Fourth, A: Install Apache, go to download an Apache installation file, download the file name: apache_1.23-win32-x86-no_src.exe, run it directly and press the default directory to C: / Program Files / Apache Group / Apache below. Note: When installing this version of Apache, you will automatically find your servername, and automatically set the port number 80 and ask you to fill in the contact E-mail address of the Administrator, everything is default. B: Configure Apache, open the http.conf file under C: / Program files / apache group / apache / confed with Notepad, find: #Listen 3000 #Listen 12.34.56.78:80 two lines, remove the front ##, Change the above two rows to: listen 80 #Listen XXX.XXX.XX.XXX: 80 where xxx.xxx.xx.xxx is your IP address. Then find the port and confirm it after: 80; then find the servername and confirm that it is not your computer name as: worker16.soft.com (note that the name is clear, below To), where worker16 identifies the name of your computer, Soft.com is the domain name where your Win2K is located.</p> <p>C: Here, your apache is just fine, test it: Enter: http://xxx.xxx.xx.xxx in IE See if there is an Apache default directory page.</p> <p>V. Combine Apache and Tomcat with mod_webapp, allowing Apache to support JSP functions. A: Go to www.apache.org to download MOD_WEBAPP for Windows, the file downloaded is: WebApp-module-1.0-tc40-windows.zip. Unzip it into a directory such as TEST.</p> <p>B: Copy libapr.dll in the TEST directory below below, Note that this directory is a directory for Apache installations. In this directory, there are also directorys such as lib, libexec, bin, logs, ie, libapr.dll, to place it in the root of Apache installation.</p> <p>C: Copy the mod_webapp.so file in the TEST directory to C: / Program Files / Apache Group / Apache / Modules.</p> <p>D: Use Notepad to open the C: / Program files / apache group / apache / conf / http.conf file, in the "last" plus the following lines: loadModule WebApp_Module Modules / Mod_Webapp.so WebAppConnection WarpConnection Warp localhost: 8008 WebAppDeploy Examples WarpConnection / Examples / EXAMPLES /</p> <p>E: Open the C: / Program Files / Apache Tomcat 4.0 / conf / server.xml file with Notepad, find the following lines below: <! - define an apache-connection service -> <service name = tomcat-Apache "> <Connector className =" org.apache.catalina.connector.warp.WarpConnector "port =" 8008 "minProcessors =" 5 "maxProcessors =" 75 "enableLookups =" true "appBase =" webapps "acceptCount =" 10 "Debug =" 0 "/> <!" To "Tomcat-Apache" in the above service name = "Tomcat-Apache" For your computer name: the worker16.soft.com set above. The above line should be: <! <Service name = "worker16.soft.com"> <connector classname = "org.apache.catalina.connector.warp.warpConnector "Port =" 8008 "minprocessors =" 5 "maxprocessors =" 75 "enablelookups =" true "AppBase =" WebApps "acceptcount =" 10 "debug =" 0 "/> <! - replace" localhost "with what you have apache "ServerName" is set to -> store. To do this, Tomcat and Apache are connected up. Sixth, 1: Test whether apache holds JSP to open IE, enter: http://xxx.xxx.xx.xxx/myjsp/HelloWorm.jsp You can see the page, you can see it. The result of JSP runs. 2: Test the Apache to open the IE in the address bar: http: //xxx.xxx.xx.xxx/hello.do can see the page, run the example, you can see the result of the servlets .</p> <p>So far, a system environment written in JSP is configured. Is it easy, everything else is installed by default, then a small change part, everything is done. If you use it for your personal learning, you can only install Tomcat, that is, the fourth and fifth steps are not performed.</p> <p>7: Supplementary description: 1: When running your own servlet, if you change the .java source, you need to recompile, and you need to restart Tomcat and Apache. When needed, you also need to reset the web.xml file. When using Tomcat and Apache, you need to start Tomcat first, then start Apache. 2: When setting up Web.xml above, you can also pass parameters to the servlet, how to do it, please refer to Tomcat's instruction file. 3: When using: <servlet-maping> <servlet-name> hello </ servlet-name> <url-pattern> *. Do </ url-pattern> configuration in the web.xml program. Use http: //xxx.xxx.xxx.xx: 8080 / hello.do and http: //xxx.xxx.xxx.xx: 8080 / servlet / hello can be seen, I don't know why? If you find the reason during use, please tell me: abnertsai@sina.com Thank you! 4: Supplement How to configure Tomcat users and use web-based remote management tools to open the CONF directory in the Tomcat installation directory with Notepad The Tomcat-Users.xml file, you can see the following: <! - NOTE: BY Default, no user is incrured in the "manager" role required to operate the "/ manager" Web Application. If wish to use tris App, You Must Define Such a User - The UserName and Password Are Arbitrary .--> <Tomcat-Users> <user name = "tomcat" password = "tomcat" roles = "tomcat" /> <user name = "role1" Password = "Tomcat" roles = "role1" /> <user name = "Both" password = "tomcat" roles = "Tomcat, role1" /> </ tomcat-users></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-26580.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="26580" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.046</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'Igx6O_2F5rIuzdWqmKaNXXiNDFhMDC09Dz4e8m1NvmxGV7lAdmPIiGl3Sf2bxieQkIBfz28UTBfmCf39NJ9hkjdA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>