JDK + Apache

zhaozj2021-02-12  231

JDK APACHE_2.0.47 Tomcat-5.0.19 Combined Configuration (2)

- The most comprehensive good information on the Internet (who said? The author said)

Author: weibin (welcome to reprint, please retain the right of authorship)

After successful connection, the following test is performed

11, the JSP page test

Write a simple myIndex.jsp content as follows:

<% @ Page ContentType = "Text / HTML; Charset = GB2312" Language = "Java" Import = "java.sql. *" ErrorPage = ""%>

<% @ Page Import = "java.util.date"%>

No title document </ Title></p> <p></ hEAD></p> <p><body></p> <p>The server is already started! <br></p> <p>The current system time is <% = new date ()%></p> <p></ body></p> <p></ html></p> <p><! - ******** * *********** -></p> <p>Save the above file in the D: / Tomcat5 / WebApps / root directory:</p> <p>Open two IE windows, the address bar is</p> <p>http://localhost/myindex.jsp</p> <p>Http: // localhost: 8080 / myIndex.jsp</p> <p>The results are:</p> <p>The server is already started!</p> <p>Current system time is Fri Apr 09 14:51:26 CST 2004</p> <p>The description is successful (if you don't have to try to restart the machine, the following is also, often configured, the configuration is correct, but you can't immediately see the machine, sometimes you can write or stop the service and start the service is not good. Why is this, I don't know)!</p> <p>12, custom project directory specification</p> <p>Let's talk about the point of virtual machine and virtual directory (that is, my own project):</p> <p>Also set the virtual host (actually above or the project folder under Tomcat5, can be specified, as I assign to "D: / Java / AA", "D: / Java / AA" for my project The root directory of the group, of course, may not be specified, then, you can save the JSP file in the D: / Tomcat5 / WebApps / root / directory, class files are available to D: / Tomcat5 / WebApps / root / web- INF / CLASSES / directory)</p> <p>Modify the corresponding part of the httpd.conf / httpd.conf under D: / Apache2 / Conf (this time my virtual directory is D: / java / aa)</p> <p># --------------------------------------- #</p> <p><Virtualhost localhost> #localhost is this machine, you can use this unit IP</p> <p>ServerAdmin weibin975@sohu.com # Your mail address</p> <p>DocumentRoot D: / java / aa # My project group root directory D: / java / aa</p> <p>ServerName Localhost # Your service name, if your machine has domain name, set it to domain name, but the software is used to test ErrorLog logs / robornet_home_log.txt # Error log, in D: / apache2 / logs</p> <p>Customlog logs / robornet_custom_log.txt Common # Access Log</p> <p>JKMOUNT / servlet / * ajp13 # Let Apache support to transmit to servlets to Tomcat resolution</p> <p>Jkmount /*.jsp Ajp13 # Let Apache support to transfer JSP to Tomcat resolution</p> <p></ Virtualhost></p> <p># --------------------------------------- #</p> <p>Then set Tomcat to support my project, open the d: /tomcat5/conf/server.xml file,</p> <p>Add "</ context>" before "</ Host>"</p> <p><Context path = "/ aa" DOCBASE = "D: / java / aa" debug = "0" reloadable = "true" crosscontext = "true" /></p> <p>And save.</p> <p>(If necessary, restart your computer, turn on the Apache server after restart)</p> <p>Put the MyIndex.jsp files in the above COPY to D: / Java / aa directory</p> <p>The modification is as follows:</p> <p><! - ******** beguing *********** -></p> <p><% @ Page ContentType = "Text / HTML; Charset = GB2312" Language = "Java" Import = "java.sql. *" ErrorPage = ""%></p> <p><% @ Page Import = "java.util.date"%></p> <p><html></p> <p><HEAD></p> <p><meta http-equiv = "content-type" content = "text / html; charSet = GB2312"></p> <p><title> No title document </ Title></p> <p></ hEAD></p> <p><body></p> <p>Custom project test <br></p> <p>The server is already started! <br></p> <p>The current system time is <% = new date ()%></p> <p></ body></p> <p></ html></p> <p><! - ******** * *********** -></p> <p>Open an IE window, in the address bar:</p> <p>http://localhost/aa/myindex.jsp</p> <p>Http: // localhost: 8080 / aa / myindex.jsp</p> <p>The result of the two page shows:</p> <p>Custom project test</p> <p>The server is already started!</p> <p>Current system time is Fri Apr 09 19:39:52 CST 2004</p> <p>This shows that the custom project is used, don't be happy too early ... stay!</p> <p>Description: All configurations above If there are spaces in the path, use quotation marks. It is also easy to make an error.</p> <p>13. Customize file structure in the project directory</p> <p>As shown in D: / Tomcat5 / WebApps / Root /, you can build a "web-inf" folder, build a "Classes" folder, write a Java class or JavaBean to generate the class file or compile generation In the "D: / Java / AA / Web-INF / CLASSES /" directory, (the best way is to put the Java source file in this directory, compiled Class files or classes in this directory After the first generation of class files, when referenced in the JSP page, you may have an exception of the class, don't worry, restart your computer, it is easy to use, maybe in some places in the forebel, just I am Debug configuration, I'm writing this article, I am afraid I can't remember, there is no relationship, when you configure it, if you think it is correct but you can't realize: Restart your computer is the only spiritan medicine, don't laugh, it is true) An example of JavaBean to help you understand the above "custom project file structure"</p> <p>Then, according to the method mentioned above, the directory Web-INF and its subdirectories Classes are</p> <p>Write one in the Classes directory</p> <p>//Helowow.java</p> <p>Package beans;</p> <p>Public class hellow</p> <p>{</p> <p>Private string wb;</p> <p>Public void setValue (String WB)</p> <p>{</p> <p>THIS.WB = WB;</p> <p>}</p> <p>Public String getValue ()</p> <p>{</p> <p>Return THIS.WB;</p> <p>}</p> <p>}</p> <p>After compiling, there is a beans directory under the class directory, and there is a help.class instructions for compilation!</p> <p>Write a JSP file in the D: / java / aa directory (TestJavaclass.jsp), the content is as follows:</p> <p><% @ Page ContentType = "text / html; charset = GB2312"%></p> <p><% @ Page Import = "Beans.Hellow"%></p> <p><Html></p> <p><HEAD></p> <p><Title> Reusing JavaBeans in JSP </ Title></p> <p></ HEAD></p> <p><Body></p> <p><%</p> <p>Hellow hell = new hellow ();</p> <p>HEL.SetValue ("weibin");</p> <p>Out.println (HEL.GetValue ());</p> <p>%></p> <p></ Body></p> <p></ html></p> <p>Open a window test: http://localhost/aa/testjavaclass.jsp</p> <p>The result of me is that the page is wrong. The reason is that the reason is not to find the class hellow. In fact, what is the existence of this class, what to do, don't worry, restart the machine! When it is necessary to eliminate the correct display, (if it is right, certainly, it is good for you, for me, my psychology is unbalanced, why don't you restart, I have to restart, don't, you have to restart ... ...)</p> <p>Start the APACHE server after restart.</p> <p>Open a window test: http://localhost/aa/testjavaclass.jsp</p> <p>If you have a name:</p> <p>weibin</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-6264.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="6264" 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.039</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 = 'w8R4sQ0CM2BQJq1yhqNYfpX9f4g4SWaa8IVZXUvvvtUWFY3nYU_2FN3o9nYjb4w9_2FWogDUlmfGKemHK_2FyMR9Exnw_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>