Debug JSP using Lomboz

zhaozj2021-02-16  49

Debug JSP using Lomboz

Ube bun (james.hu@chinacodeline.com)

Xi'an Software Co., Ltd.

September 2003

Foreword

Anyone who has JSP written experience has a hard experience in JSP debugging. Since the lack of automated debugging tools makes a lot of print statements that have to be used in the file when debugging JSP. This approach is a simple and effective means for the location of the JSP range, but how to quickly and efficiently position the internal error of the object called in the JSP. It is a bit unhappy. Because this will have to compile, release, start and stop the server, bringing great inconvenience to debugging.

The Legend of the JSP debugging tools you have obtained, don't exist on the situation currently mastering. If the reader has the hope of this information, huh, huh. But JSP debugging tools do exist, and it is free! IT's Lomboz. Download address: http://www.objectLearn.com/products/download.jsp

From a simple example, this paper describes how to use Lomboz to debug JSP. The development environment of this example is as follows:

- JDK version: 1.4.1;

- Java Ide: Eclipse 2.1;

- Lomboz: Suitable for plugins for Eclipse2.1;

- JSP / servlet container: Tomcat 4.1.18.

Introduction to Lomboz

Strictly said that Lomboz is a J2EE plugin for Eclipse. It integrates many Java application servers, J2EE components, and web applications to Eclipse, which can help Java developers use Eclipse to build, test, deploy J2EE applications. For the focus of this article, JSP debugging, it also has related support:

- Support JSP writing, including: syntax coloring and syntax check;

- Support JSP debugging.

For JSP debugging, the principle of Lomboz is to debug the Java code generated by the JSP page to be debugged. The entire debugging process is the same as the debugging process of the Java application, whether it is a JSP itself debugging or a debugging of the object called by JSP, it is seamlessly coupled to a piece.

Before you begin this article, let's first look at the Lomboz installation and configures for normal use of its JSP debugging.

Installation and configuration

Lomboz installation process is very simple, and the plugin installation process of Eclipse is very simple, the main steps are as follows:

1. Download the plugin that supports Eclipse2.1 (or other versions of Eclipse) from the Lomboz download address (http://www.objectlearn.com/products/download.jsp).

2. If the Eclipse has run, then turn it off first.

3. Extract the downloaded file to the plugins directory in the Eclipse installation directory.

4. Restart Eclipse to open "About Eclipse Platform Plug-Ins" (Help -> About Eclipse Platform -> Plug-in Details), if the Lomboz installation will appear information about it. As shown below:

Note: If you want to remove Lomboz, you only need to delete the directory of the PLUGINS directory.

5. Set the Lomboz J2EE View, open Window -> Customize Perspective, as shown in Figure Set:

The next is how to configure Lomboz to make it work. Contrary to the installation process, the configuration process is not that simple, J. The Lomboz configuration steps are as follows:

1. Configure JDK, select "Windows -> Preferences", select Lomboz, and configure the JDK. This is as follows:

2. Define the server if your server is already included in the Lomboz default server list, this step can be skipped. The Lomboz default server list can be obtained by expanding Lomboz in the previous interface, then select "Server Definitions". The following is to add Tomcat4.1.18 as an example to show how to add a server. The relevant steps are as follows:

a) Enter the servers subdirector of the Lomboz installation directory, copy one .server file (such as Tomcat410.server) and rename it to tomcat418.server.

b) Open this file to change the following location of this file:

- , change the value of the name to a name you want (such as Apache Tomcat V4.1.8), this name is used to display the list of servers in the "Server Definitions" interface;

- , where default's value is changed to Tomcat on your machine, such as D: / Program Files / Java / Tomcat-4.1.18;

- , where default is changed to any name (such as Tomcat418), this name is used to represent the default ClassPath of the Lomboz project;

- , where default value is changed to the directory where Tomcat is located, such as D: / Program Files / Java / Tomcat-4.1.18;

c) Add Jasper-Runtime.jar. By default, only 2 JAR files are included in the Tomcatx.Server file: servlet.jar and bootstrap.jar, but lack jasper-runtime.jar. And this JAR file has played a very important role in JSP debugging, so please add it. There are two ways to add JAR to a server:

method 1:

Add a line in the section of the .server file: $ {classpathvariablename} /common/lib/jasper-runtime.jar ;

Method 2: Use the "Server Definitions" interface, no more details here.

Configured servers are displayed in the "Server Definitions" form, as shown below:

Note: For Tomcat4.x servers, you need to put patch to make Lomboz work, patch download address:

http://www.sysdeo.com/

At this point, Lomboz installation and configuration has all been completed, let us create an example of "Hello World!" To experience the process of lomboz debugging JSP. Debug JSP

Create project

To use Lomboz debugging JSP, you must first create a Lomboz project. Proceed as follows:

1. Open File-> New-> Lomboz J2EE Project, create a project called debugjsp;

2. Select "Next" to enter the Lomboz Engineering Properties Select page, add web modules and servers used. Since our main task is to debug JSP, the EJB module can be empty. As shown below:

3. Choose Finish, Lomboz project is created. At this point, the file structure generated by Lomboz is shown below:

Next, we can create the JSP file you need. In this example I use the default index.jsp, change its content to:

Welcome </ Title></p> <p></ hEAD></p> <p><body></p> <p><center> <% = "Hello World!"%> </ center></p> <p></ body></p> <p></ html></p> <p>As far as it is, we debug JSP preparation is roughly completed, but the person who uses Tomcat4.x needs excess steps (these steps are mainly caused by Tomcat4.x itself):</p> <p>1. Add a lower line in the server.xml file in Tomcat's config directory (see Server.xml):</p> <p><Context path = "/ testjsp" DocBase = "D: / debugjsp / debugjsp" Workdir = "D: / debugjsp / j2src / org / apache / jsp"></p> <p>Among them, PATH represents the URL name of the web application; DOCBASE represents the physical location of the web application; Workdir represents the location of the JAVA file corresponding to the JSP, must create the directory structure and name of ORG / Apache / JSP.</p> <p>2. Create a corresponding subditio structure in the corresponding J2SRC directory, and set the J2SRC as the Source directory of the J2SRC.</p> <p>Syntax check</p> <p>Now let's start enjoying the process of debugging JSP. The JSP should be no syntax error before debugging. Lomboz provides the function of JSP syntax check, and the specific operation is:</p> <p>1. Select the JSP file you want to perform syntax check, click the right mouse button;</p> <p>2. Select Lomboz J2EE ... -> Check Jsp Syntax</p> <p>debugging</p> <p>After solving the synergistic error, the next step is to solve the logical error. This error can only be solved by debugging. Using the Lomboz debugging process is very similar to the debugging of a normal Java application, because its principle is to use the server to generate a JAVA file corresponding to the JSP, and then debug them.</p> <p>The steps to debug JSP are as follows:</p> <p>1. Open the Lomboz J2EE View, select the server, click the right mouse button to select "Debug Server". As shown in: If the .server file is defined correctly, Tomcat will start. If you don't start Tomcat as expected, then troubleshoot from these two aspects: Tomcat environment variables and Lomboz Server files.</p> <p>2. Open the browser, such as IE, enter: http://127.0.0.1: 8080 / debugjsp / index.jsp. If the JSP file syntax does not have an error, the JAVA file corresponding to this JSP file will be generated in the J2SRC / ORG / APACHE / JSP directory. Refresh the project to see these files. Figure:</p> <p>This step is mainly to trigger the server based on JSP's Java files that can be debugged, do not have to be precise. Because once the Java file is generated, these errors can be excluded by debugging.</p> <p>3. Open this Java file, set the breakpoint in it, then enter this URL again in the address bar of the IE. At this time, the Eclipse debugging function is activated. At this point, JSP can be commissioned, and the situation is as follows:</p> <p>As for the debugging of the object called the JSP, after completing the above steps, then set the breakpoint in the Java file corresponding to the object.</p> <p>Conclude</p> <p>Although the current JSP debugging is not convenient to be as convenient to regular Java file, the appearance of the Tomboz tool has at least the stage of manual debugging JSP. Since this Java's web application developer does not have to stop the program from time to time to manually add a printed statement to observe the value of the variable, the opposite can observe the changes in the program while debugging the normal Java app. This greatly facilitates the development of web applications, which reduces the time to be wasted for debugging.</p> <p>Reference</p> <p>l Jiang Yan's "Using Eclipse Development J2EE Application" introduced how to develop J2EE applications using Lomboz;</p> <p>l Lomboz Official Website www.objectLearn.com, there is a documentation and related tutorials on Lomboz;</p> <p>l Eclipse's official website www.eclipse.org;</p> <p>l Eclipse In Action, a good book on eclipse in an extraction;</p> <p>L Tomcat's official website http://jakarta.apache.org/tomcat/index.html;</p> <p>About author</p> <p>Hulu, Master of Engineering, Xi'an Jiaotong University, is keen on J2EE / .NET technology, is the loyal advocator of OpenSource. At present, Xi'an Software Co., Ltd. is currently created with friends. The company is mainly committed to the development of Java web applications, and many projects have been applied in energy, electricity and transportation industries. You can contact him through James.hu@chinacodeline.com.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-24846.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="24846" 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.057</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 = 'bdRI_2F2xhuBzaql9RPrYIXHzZ2TbfVIvBlHUdcQ0V8qSybTVLJ5EnrxNGTXQGuDIq2iE20OxYgdkGcZ7_2BqjNYHw_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>