Configuration of JSP development environment under Windows

xiaoxiao2021-03-06  18

Summary To learn JSP development, you must first build a development environment that meets JSP specifications. This paper introduces a method of configuring a JSP environment based on Tomcat servers as a practical principle.

Keyword JSP engine, web server, configuring SUN-launched JSP (Java Server Pages) is a dynamic web development technology that is executed on server-side, which is based on Java technology. When executing JSP, you need to set up an engine that compiles the JSP web page on the web server. Configuring a JSP environment can have a variety of ways, but main work is to install and configure web servers and JSP engines.

Below Tomcat as a JSP engine, with Tomcat, Apache, IIS, three web servers, three ways to build JSP running environments.

First, related software introduction

1, J2SDK: Java2 software development tools are the foundation of the Java application. JSP is based on Java technology, so you must install J2SDK before configuring the JSP environment.

2, Apache Server: A common web server developed by Apache organizations, providing web services.

3, Tomcat Server: Apache organization developed a JSP engine that itself has a web server function, which can be used as a stand-alone web server. However, as a web server, Tomcat is not as fast as Apache, nor Apache, but there is no Apache, so we generally use the Tomcat and Apache to provide services to the website's static page request, while Tomcat is a dedicated JSP Engine, providing JSP parsing to get better performance. And Tomcat itself is a sub-project of Apache, so Tomcat provides strong support to Apache. For beginners, Tomcat is a very good choice.

4, MOD_JK.DLL: Apache Organize the Jakarta project group developed the Apache support Tomcat plug-in. With this plugin, Tomcat can seamlessly connect with Apache.

5, TC4NTIS.ZIP: APACHE Organize the Jakarta project group to develop the IIS support Tomcat plug-in.

Second, the software download

1, J2SDK

Version: J2SDK1.4.1 (35.9MB)

Address: http://java.sun.com/j2se/1.4.1/download.html

2, Apache2

Version: Apache2.0.43 (6.69MB)

Address: http://www.apache.inetcosmos.org/dist/httpd/binaries/win32/

3, Tomcat4

Version: 4.1.21 (8.33MB)

Address: http://jakarta.apache.org/builds/jakarta-tomcat-4.0/Release/

4, MOD_JK.DLL: (136KB)

Address: http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/

5, TC4NTIIS.ZIP (220KB)

Address: http://members.ozemail.com.au/~lampante/howto/tomcat/iisnt/tc4ntiis.zip

All above is free software.

Third, preparation before configuration

(1) Preparing a JSP page for testing

Open a text editor, such as Notepad, enter the following code, and save it as test .jsp (note the extension is .jsp). JSP test page </ title> </ head> <body> <% out.println ("<h1> hello world! </ H1>));%> </ body> < / Html></p> <p>(2) Install J2SDK</p> <p>Regardless of the solution, you must complete the J2SDK installation before installing and configuring the JSP engine.</p> <p>1, install J2SDK</p> <p>Under Windows, run the downloaded J2SDK-1_4_1_01-windows-i586.exe file directly, install it to a directory according to the installation wizard, for example, to F: / J2SDK 1.4.1;</p> <p>2, add environment variables</p> <p>(1) If your operating system is Win 98, you can edit autoexec.bat directly with Notepad, add the following command line:</p> <p>PATH =% path%; f: /j2sdk1.4.1/binset java_home = f: /j2sdk1.4.1set classpath = f: /j2sdk1.4.1/lib/tools.jar</p> <p>After saving, restart your computer so that the environment variable added is valid.</p> <p>(2) If your operating system is Win2000, then configure environment variables as follows. Right-click My Computer, select "Properties" → "System Features" → "Advanced" → Environment Variables in the pop-up menu, and the Environment Variable dialog box can edit the environment variable. Add three variables in Path, Java_Home and ClassPath, and the variable value.</p> <p>Fourth, JSP environment configuration program</p> <p>(1) Scheme 1: J2SDK Tomcat</p> <p>In this scenario, Tomcat acts as a JSP engine as a web server, and the configuration is relatively simple.</p> <p>1, install Tomcat</p> <p>Directly run download jakarta-tomcat-4.0.1.exe, follow the general Windows program installation steps to install Tomcat, which will automatically look for the position of J2SDK. For example, install it to F: / Tomcat4.</p> <p>2, configure Tomcat environment variables</p> <p>Add a new environment variable tomcat_home, the variable value is f: / tomcat4, add the method to the configuration method of the J2SDK environment variable.</p> <p>3, test default service</p> <p>You can run the Tomcat server after setting up. Start Tomcat with f: /tomcat4/bin/startup.exe, close with f: /tomcat4/bin/shutdown.exe. (If you prompt the Out of Environment Space error while executing Startup.exe or ShutDown.exe, select "Properties" → "Memory" → "General Memory" in the DoS window, and modify the "Automatic" "2816" is ok.)</p> <p>After starting Tomcat, open the browser and enter http: // localhost: 8080 in the address bar (Tomcat default port is 8080), if you see Tomcat's welcome interface in the browser, it means that Tomcat works fine. 4, test project</p> <p>Put the test.jsp just prepared, in the F: / Tomcat / WebApps / Examples / JSP directory, enter http: // localhost: 8080 / examples / jsp / test.jsp in the address bar, if the browser is displayed Hello World! ", Indicating that your JSP environment is successful!</p> <p>Since Tomcat itself has a web server, we don't have to install Apache, of course it can also be integrated with Apache, hereby.</p> <p>(2) Plan 2: J2SDK Apache Tomcat</p> <p>Although Tomcat can also make a web server, the speed of the static HTML is less than Apache, and its functionality is far less than Apache, so the Apache and Tomcat are integrated, and the Apache acts as a web server, and Tomcat is dedicated. JSP engine. The configuration of this solution is more complicated, but it enables Apache and Tomcat to integrate, and achieve powerful functions.</p> <p>Note that because the IIS web server uses the 80 port by default, the Apache's default port is also 80, so if you use the Win2000 operating system, and pre-installed IIS, for convenience, please stop the IIS service before doing the following.</p> <p>1, install Apache</p> <p>Run the downloaded apache_2.0.43-win32-x86-no_ssl.exe, install it to F: / Apache2 according to the wizard. (Note that after the installation of Apache2.0.43, the index.html.en under the F: / Apache2 / HTDOCS directory must be renamed to index.html so that the Apache's welcome interface will be displayed normally when testing the default service).</p> <p>2, test Apache default service</p> <p>After installation, the Apache server has run automatically. Open the browser, type in the address bar: http: // localhost (Tomcat default port is 80), if you see the welcome interface of Apache in the browser, the Apache is working fine.</p> <p>3. Install Tomcat as follows, and ensure that it runs normally.</p> <p>4. Copy the downloaded mod_jk-2.0.42.dll to the F: / Apache2 / Modules directory.</p> <p>5. Establish the work file required for the MOD_JK module work.</p> <p>Open the text editor, enter the following statement:</p> <p>Workers.tomcat_home = f: / tomcat4 (let the MOD_JK module know Tomcat) workers.java_home = f: /j2sdk1.4.1 (let the MOD_JK module know the jsdk) ps = / worker.list = AJP13 (Mode version of MOD_JK) worker.ajp13. Port = 8009 (MOD_JK working port) worker.ajp13.host = localhost worker.ajp13.type = ajp13 worker.ajp13.lbFactor = 1</p> <p>Save the above statement in the F: / Tomcat4 / Conf directory in workers.properties (Note: The extension of the file is .properties). 6. Configure Apache.</p> <p>Open f: /apache2/conf/httpd.conf with text editor</p> <p>1) Find "DirectoryIndex", add index.jsp after index.html.var;</p> <p>2) At the end of httpd.conf, the following paragraph (explained in parentheses)</p> <p>LoadModule JK_Module Modules / MOD_JK-2.0.42.dll (Loading MOD_JK module, connection to process Apache and Tomcat) JKWorkersFile "f: /tomcat4/conf/Workers.properties" (indicating that the MOD_JK module is required to work for work file workers. Properties location) JKMount / servlet / * ajp13 jkmount /*.jsp Ajp13 (send all servlets and JSP requests to Tomcat through the AJP13 protocol, let Tomcat to process)</p> <p>3) Save after the addition is completed.</p> <p>7, configure Tomcat</p> <p>Use the text editor to open f: /tomcat4/conf/server.xml. Because Tomcat4 does not enable AJP13 by default, find out the following code:</p> <p><! - <Connector ClassName = "org.apache.ajp.tomcat4.ajp13connector" port = "8009" minprocessors = "5" maxprocessors = "75" acceptcount = "10" debug = "0" /> -></p> <p>Delete the comment symbol <! -> to enable AJP13.</p> <p>Then save, now Tomcat and Apache's integrated configuration is basically completed.</p> <p>8, overall test</p> <p>Put Test.jsp in the F: / Tomcat / WebApps / Examples / JSP directory, start Apache2, Tomcat4 in turn. Open the browser, enter http: // localhost: 8080 / example in the address bar, if "Hello World!" Appears in the browser, then the Tomcat is reconfigured, and it works fine; enter HTTP in the address bar : // localhost / examplep, if the result is the same as http: // localhost: 8080 / example / jsp /test.jsp, then the Apache and Tomcat are successful!</p> <p>(3) Solution 3: J2SDK IIS Tomcat</p> <p>The most commonly used web server under the Windows platform is undoubtedly IIS. Under normal circumstances IIS do not support JSP, we can use an IIS to Tomcat to redirect plugins, allow IIS to send all JSP requests to Tomcat, allowing IIS to increase processing JSP function. If you are used to using IIS, you can try this configuration. (If you have already installed the Apache server, please uninstall Apache in order to make it easier.)</p> <p>1. Install Tomcat as follows, and ensure that it runs normally. (For example, installing to F: / Tomcat4); 2. Download the downloaded TC4NTIS.ZIP directly to the F: / Tomcat4 directory. Check the file required by the configuration, make sure they are in the following locations:</p> <p>F: /tomcat4/server/lib/ajp.jar f: /tomcat4/server/lib/tomcat-util.jar f: /tomcat4/bin/native/isapi_redirect.dll f: /tomcat4/conf/ntiis/workers.properties f: /tomcat4/conf/ntiis/uriworkkermap.properties f: /tomcat4/conf/ntiis/iis_redirect.reg f: /tomcat4/log/iis_redirect.log</p> <p>3, open F: /Tomcat4/conf/ntiis/workers.properties with text editor, modify the following value:</p> <p>Workers.tomcat_home = f: /tomcat4workers.java_home=f: /j2sdk1.4.1</p> <p>4, double-click F: /Tomcat4/conf/ntiis/iis_redirect.reg, add the information within this registration file to the registry, but to modify the key value of the three keys of log_file, worker_file, worker_mount_file, to suit your environment (For example, Tomcat in this article is installed in F: / Tomcat4, not the default C: / Tomcat4). After adding and modified, you will be shown below.</p> <p>5. Open the Internet Service Manager, add a new virtual directory on the default site, named Jakarta, this virtual directory points to F: / Tomcat4 / Bin / Native, and launch the default site.</p> <p>6. Right-click the server name in the Internet Service Manager, select the "WWW Service" → "ISAPI Filter" → "ISAPI Filter" → "ISAPI Filter" → "ISAPI Filter" tab, add an ISAPI filter, name is Jakarta Redirect, the executable is specified as f: /tomcat4/bin/native/isapi_redirector.dll. After adding the ISAPI filter, the status of Jakarta Redirect is a red downward arrow, restarting the IIS service, turning green arrow.</p> <p>7, edit the server.xml file and save (step 7 of the same second).</p> <p>8, restart IIS and Tomcat.</p> <p>9. Test item: put the test.jsp in the F: / Tomcat / WebApps / Examples / JSP directory. Open the browser, type http: // localhost: 8080 / example in the address bar, if "Hello World!" Appears in the browser, then the Tomcat is reconfigured, and it works fine; enter HTTP in the address bar : // localhost / examplep, if the result is the same as http: // localhost: 8080 / example, the result is the same, that IIS and Tomcat are successful!</p> <p>Five, conclude</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-44689.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="44689" 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.051</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 = 'ZUv2cP71m4EmuJdDKftmw4W8rS38Iv3k7zVNmLZu4TeIkcimQ3J2jqGFDhNPZnXcjFGykFELyZ7timW7hUOqhQ_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>