Use visualageJava
Servlets isJavaThis article describes servlets and describes how to use visualage for Java to quickly develop servlets. The key technology of visualageforjava applied in servlets development is the capability of visualageforjava to simulate a variety of Virtual Machine environments, andCodeAdd edit and connect to runningProgram.
Background
In the early days of WWW, programmers quickly realized that using the public Gateway Interface (CGI), WWW could become a compelling application development platform. In fact, a CGI program is to extend various capabilities to an insert module in the web server. However, the initial CGIDesignIt is required to create a separate process for each request service, which increases the performance and resource consumption. To improve CGI performance and scalability, web server vendors have introduced proprietary APIs, such as nsapi of Netscape, ISAPI of Microsoft, and gwapi of IBM, netscape also introduced a web browser insertion API for navigator. In this way, both the Web client and server can be expanded by inserting. Unfortunately, this insert requires a dedicated APIs for differentOperating SystemDifferent versions.
The Java and defined appletapi launched by sun brings the second improvement of www. appletapi provides developers with a standard extension of Web browsers and a platform-independent method. Sun now makes Java an enterprise-class application with N layersSoftwareThe servletapi has also been released, bringing the same advantages to Web servers. Enthusiastic people can learn about servlet by visiting the http://java.sun.com, and download the documentation and JavaServlet Development Kit (jsdk) from here ). In the following discussion, we will mention jsdk1.0.1.
Run Servlet
The best way to start running servlet is to download jsdk and running example, and configure servlet on the Web server. Users can use servletrunner (srun) to test servlet. servletrunner is a small program included in jsdk and a simplified Web server. Similar to appletviewer, as long as the applet is connected in a row, it becomes a simplified web browser.
Assume that the user is working on the WindowsNT platform and has installed jsdk1.1.x or jsdk1.0.1. Open a command prompt and go to the jsdk directory, for example, E: \ jsdk. In this directory, the bin subdirectory contains the servletrunner, And the servlet subdirectory contains the servlet example. Enter the servlet subdirectory and enter the following command:
E: \ jsdk \ servlet> .. \ bin \ srun-V
Now we have a web server listening for port 8080. The "-V" option generates detailed output to the Command Prompt window. Next, open any web browser, such as the navigator of the web site, and open http: // 127.0.0.1: 8080/servlet/helloworldservlet. Servletrunner loads the helloworldservlet class, constructs an environment for it, calls its Init () method, and then calls its service () method. The Service () method has a request parameter and response parameter. The helloworldservlet object simply writes an HTML homepage for the response object, which is returned to the web browser and displayed. After the first service request, the servlet remains active and on standby, which can process further requests. Servlet construction must be able to process multiple concurrent service requests, because each request starts from its own thread. When the servletrunner terminates, it calls the Servlet's destroy () method.
At the end of the servlet lifecycle, you must stop and restart servletrunner (or Web Server) to obtain an updated servlet-class file. During the development process, the user often changes the servlet code, so using servletrunner may be tedious, especially when the servlet has to debug a problem after it starts to run for a while. Fortunately, visualageforjava from IBM provides a more efficient way to develop servlet software.
To stop servletrunner, type ctrl-C in the Command Prompt window.
Visualage for Java has two key technologies that make servlet development very convenient: one is the simulation of multiple virtual machine environments, and the other is the addition of code editing and connection to the runningProgram.
Jsdk includes servletrunnerSource code(Srun. C), if you carefully examine it, you will see that servletrunner is simply running the sun. servlet. http. httpserver class. Because servletrunner is a Java program, it can be run as a Simulated Virtual Machine environment in visualageforjava. Start visualageforjava and create a new project called jsdk. Decompress the E: \ jsdk \ Lib \ classes.zip file and output it to a temp directory (or simply copy it to classes. jar), and input the class file (or jar file) to the jsdk project. In this case, some classes supported by the netscapeweb server are lost in the classes.zip file. Delete sun. servlet. NetscapeSoftwareTo clear these issues, select the sun. servlet. http. httpserver class and run it (provide the-V parameter to output the detailed results to the console window ). Now, the development environment is a web server!
Next, for example sevlets, input the source code from the E: \ jsdk \ servlrts directory to the jsdk project, expand the helloworldservlets class in the project tab in the workbench window, and select the dogeto method. In the source pane, place an insert point at the beginning of the row with the following content: Out. printin (helloworld); insert a breakpoint and reload helloworldservletsurl in the Web browser. Change the command to: Out. Print ("Hello visualage"); then, store the change. Visualageforjava only edits the modified class method and connects it to the running program. It is important to realize that adding edits is only half of the process. The real efficiency is that you do not have to restart the program being debugged or recreate the execution status of the program that causes the problem, the execution status of the program generates these problems, and the user is trying to solve them.
Check any variables of interest through several lines of program code, click the resume button to complete the service request, and the modified HTML page will appear in the Web browser.
With visualageforjava, you can modify the running servlet, so it is unnecessary to stop and start the Web server repeatedly. In addition, when the server is running, the user will still have all desired development environments.
Conclusion
Servlet is an important improvement in Web application development. Visualageforjava provides good support for developing Servlets, adding edits, and connecting to running programs through servletrunner. In the future, IBM will expand the Web connection technology to the connections between smalltalk and C ++ to Java to further enhance servlet support. With the help of IBM software technology, users can use visualageforjavacompositioneditor from htmljavabean to create servlets visually.