Develop debugging servlet (1) using JBuilder

zhaozj2021-02-11  189

Develop debugging servlet (1) using JBuilder

Huang Wei, Lu Bowi

Borland JBuilder 2.0 (JBuilder) is a leader in the Java development tool, which provides servlet Wizard helps users for servlet development and debugging. The following describes the steps to develop debugging using JBuilder 2.0 for servlet. 1. Install JSDK, establish a servlet development environment When you use JBuilder to develop debug servlets, because servlet runs in JBuilder IDE, starts the Sun.Servlet.http.httpserver class, there is no longer need to support the servlet from the development of debugging. server. JBuilder 2.0 itself does not include the class library necessary to develop servlets, so JSDK must be installed. At the same time, the class library that debugging in JBuilder 2.0 is the JDK 1.1.6_borland, which is brought by JBuilder 2.0, so it is impossible to use the JBuilder debugging Java 1.2 program, so although the development servlet is required in Java 1.2. Class libraries, you must use Java 1.2 to develop in JBuilder. JSDK can download from JavaSoft's site free download, its address is: http://jserv.javasoft.com/products/java-server/download JSDK, you need to install, this article assumes JSDK to be installed to C : / JSDK directory. 2. Add JSDK libraries to JBuilder in JBuilder, in addition to the Java core library, all other Java libraries need to be customized and setup in the JBuilder environment, so that JBuilder can find these Java libraries correctly, JBuilder provides Swing 1.01, JBCL 2.0, JGL 3.1.0, Visibroker 3.2, etc. Java libraries. When developing the servlet, we need to add JSDK libraries for supporting servlet development and debugging to JBuilder. The steps are as follows: (1) Creating an empty Project in JBuilder, the name of Project uses the default untricled1.prj; 2) Enter the engineering property dialog box by menu file | (3) Click the Libraries button to enter the Java library dialog; (4) Click the New button to define the JSDK library, as shown in Figure 1, the value set is as follows (assuming JSDK Installed in a C: / JSDK directory): name = jsdk class path = c: /jsdk/jsdk.jar Source Path = C: / JSDK / SRC DOC PATH = C: / JSDK / DOC 3. Increase the main program class using JBuilder The most important step of debugging Servlet is to add a master class class in the program, starting a "internal" web server for debugging through this class.

The steps are as follows: (1) Select New; (2) Select Class to select Class to clear all options, add an empty class named myclass1 to the project; (3) Editing MyClass1 code as follows: package untricled1 Public class myclass1 {public static void main (string args []) {sun.servlet.http.httpserver.main (args);}} Myclass1 is actually the main preface class of the usual Java application, which is in main ( The function is called by the following: Sun.Servlet.http.httpserver.main (); to run a "small" web server for the trial. 4. Setting the project file attribute After adding JSDK libraries to JBuilder, we also need to make some necessary settings for the project file. Enter the Engineering Properties dialog box by menu file | Project Properties, the following settings are made: (1) You must specify "JDK 1.1.6_borland" in Target JDK Version to debug the servlet; (2) The OUTPUT path of the specified project is C: / JSDK / Examples, such JBuilder directly places the compiled .class file in the jsdk's Examples directory; (3) Setting the RUN / Debug property: • Set the default execution file to Myclass1.java, Ensure that JBuilder finds the program entry when commissioning; • Set the program startup parameters, these parameters are actually called: Figure 1

Sun.servlet.http.httpserver.main (); the required startup parameters, all of which are the following important parameters, the following: -d servlet directory-SERVLET, the file defines servlet Name, execution class, start parameters, etc. Here we set the starting command line parameters to "-p 8020 -dc: / jsdk / servlets-sc: /jsdk/examples/servlet.properties", that is, servlet runs in port 8020, class files for servlets are placed in directory C : / jsdk / servlets, the Servlet's profile is c: /jsdk/examples/servlet.properties (Figure 2).

转载请注明原文地址:https://www.9cbs.com/read-3534.html

New Post(0)