Java to STRUCTS (transfer)

xiaoxiao2021-03-06  97

1.1 What is Java

Java has two meanings: Java language, Java platform

As a language, Java is a cross-platform development language that develops across platform applications and applications. For example: Oracle 8i installer is developed with Java. The Java language has the following features: simple, object-oriented, distributed, interpretation, security, cross-platform, high performance, multi-threaded features. As a platform, the Java platform includes two parts: Java virtual machines and Java APIs.

1.2 Java's most

Best integrated development tool

NO1. Visualage for Java (www.ibm.com)

NO2. JBuilder 3 (www.inprise.com)

NO3. JDeveloper (www.roacle.com)

NO4. Visualcafe

I recommend using Emacs

Best application server

NO1. WebObjects (www.apple.com)

NO2. WebSphere Application Server Enterprise Edition V3.0 (www.ibm.com)

NO3. Apache Jserve (java.apache.org)

NO4. WebLogic Server

I recommend Tomcat (Jakarta.apache.org), enhydra (www.enhydra.org)

The best Java class library

NO1. THE JAVA Collections (www.sun.com)

NO2. IBM Host Access Library API for Java (www.ibm.com)

NO3. JCLASS Enterprise (www.klgroup.com)

NO4. JGL

Best Java middleware

NO1. Sybase Enterprise Application Server (www.sybase.com)

NO2. WebSphere Host On-Demand V4 (www.ibm.com)

NO3. Progress Sonicmq (www.sonicmq.com)

NO4. VisioBroker

I recommend using Cocoom (XML.Apache.org), Struts (Jakarta.apache.org), Turbine (Java.apache.org)

The best Java components

NO1. Bea Jumpstart Ebusiness Smart Components (www.bea.com)

NO2. JCLASS Enterprise Suite (www.klgroup.com)

NO3. Lingogui (www.slangsoft.com)

NO4. Stdioj

Best database products

NO1. Oracle 8i (www.roacle.com)

NO2. Sybase Adaptive Server Anywhere (www.sybase.com)

NO3. Cloudscape (www.informix.com)

NO4. JDATASTORE

I recommend POSTGRESQL

Best Java virtual machine

NO1. Java Hotspot Performance Engine (java.sun.com)

NO2. Chaivm (www.hewlett-packard.com)

NO3. JSCP (www.nsicom.com)

NO4. Jeode Platform

Best message tool

NO1. Java Message Queue (www.sun.com)

NO2. SonicMQ (www.sonicmq.com)

NO3. Fioranomq (www.fiorano.com)

NO4. Ibus

The above ranks from JDJ NOV 2000 statistics.

Java and Web applications

He button, hjnet@163.net

V0.1, 14 Nov 2000 I took a short period of time I made this document in the forum, in order to give you a reference, welcome to propose valuable advice. I used the original SGML format when writing this article, and turned into the format you see via SGML-Tools. SGML-Tools is a set of text-based tools that convert simple SGML documents into formatted various files, including HTML, TEX, DVI, PostScript, Plain Text, Groff, etc. Thanks to the contributions made by all the developers of SGML-Tools. This article is copyrighted by the Chinese Linux Forum.

2. ANT introduction

Ant is a Java-based build tool. Everyone knows that there is already a lot of Build tools, such as make, gnumake, nmake, jam, etc., and these tools are very excellent. Then why should I introduce to the new tool of Ant? Because Ant is a cross-platform Build tool. The reason that Ant can cross the platform because Ant no longer needs you to write shell commands, Ant's profile is XML-based task tree, which allows you to run a variety of tasks, the task run is the implementation of a specific task interface Objects are completed.

2.1 get an Ant

Binary version: The latest stable version of the download address is: http://jakarta.apache.org/builds/ant/release/v1.1/bin.

SOURCE Edition: The latest source stabilization download address is: http://jakarta.apache.org/builds/ant/release/v1.1/src/. If you want to get the latest source code, the address is: http://jakarta.apache.org/from-cvs/jakarta-ant/

2.2 System Requirements

You need to include XML Parser compatible with JAXP in ClassPath to compile and use ANT.

I recommend an XML Parser: Xerces, Downloads: http://xml.apache.org/xerces

Of course, JDK is definitely necessary and is a 1.1 or later version.

2.3 Compile ANT

1. Enter the Jakarta-Ant directory

2. Add JDK to your PATH environment variable

3. Set the java_home environment variable to point to your JDK installation directory

4. Run Bootstrap.SH angle file

5. Run the following command to create a binary version of Ant:

Build.sh -dant.dist.dir = DIST

2.4 Installing Ant

1. Set an ANT_HOME environment variable to point to your Ant directory

2. Set the java_home environment variable to point to your JSK directory

3. Add ant_home / bin to the PATH environment variable

4. Add Ant.jar and Xerces.jar to the ClassPath environment variable

Suppose Ant is installed in the / usr / local / ant directory, you can set the following:

Export Ant_Home = / usr / local / Ant

Export java_home = / usr / local / jdk-1.2.2

Export Path = $ {Ant_Home} / bin: $ {pat}

Export classpath = $ {ant_home} /lib/ant.jar: /lib/xerces.jar: $ {classpath}

2.5 Run Ant

Running Ant is very simple, if you install Ant according to the methods described above, just type Ant on the command line.

When you run Ant without any parameters, Ant will find a file called build.xml in the current directory. If you find it, you will use the file as the build profile. If not found, it will automatically find the upper level directory, and have always found the root directory. Other profiles can also be specified by command line parameters -buildfile , where is the configuration file name you want to use. 3. JSP introduction

JSP is a short written by JavaServer Pages. JSP technology allows Web developers and web designers to quickly develop easy-to-maintain dynamic web homepage.

The web application developed by JSP is cross-platform, which can run under Linux, and can run on other operating systems.

JSP technology writes XML Tags and ScriptleTs using Java programming languages ​​to encapsulate processing logic that generates dynamic web pages. The web page can also access the application logic of the server (such as Javabesns) existing on the server via Tags and Scriptlets. JSP will separate web logic and web pages, support reusable components-based design, making web-based applications quickly and easily.

JSP technology is an extension of servlet technology. Servlet is a platform-independent, 100% pure Java Java server component.

3.1 JSP and JAKARTA

It is because of the efforts of the Jakarta project group, which makes servlet / JSP have an unprecedented driving force.

Starting from servlet2.2, Sun has abandoned the control of servlet, and the full right is developed and maintained by the Jakarta project group. Sun no longer provides servlet / jsp development kits, but a software download is linked to Jakarta sites, and fully supports the development of Jakarta project groups (some of the Jakarta project groups have some backbone power is SUN employees). This is Sundending decision-making and the significant results of open source software.

JSP technology is one of the two template technology (JSP and Velocity) provided by Jakarta. These two are very good template technology. Jakarta's framework (such as Struts, Slide) provides a good support for JSP, and Java.apache's Framework (Turbine) provides Velocity a good support.

3.2 Run your own JSP file

Some netizens don't know how to run their JSP files, I will introduce it to you, give you a point:

1. Download and install Tomcat. Download address: http://jakarta.apache.org/tomcat

2. Write your own JSP page and Java objects.

3. Configure your own web application. Configuration method:

Add a line in the tomcat_home / conf / server.xml file:

Among them, tomcat_home is the main directory of Tomcat, appname is the name of your web application.

4. Copy your JSP file, HTML file, and image files to tomcat_home / webapps / appname directory.

5. Compile your Java file.

6. Copy the compiled Class file to the Tomcat_Home / WebApps / Web-INF / CLASSES directory. You can also pack the class file into a JAR file to put it in the Tomcat_Home / WebApps / Web-INF / LIB directory.

7. ALL IS OK! You can see your results on your browser:

Http: // localhost: 8080 / appname / youjsp.jsp.jsp

Among them, appname is your web application name, youjsp.jsp is the name of the JSP file you have written. 4. Tomcat introduction After I wrote some posts about Struts and Framework, someone asked me what is Tomcat, what is Jakarta. I found that I should write some more basic things first. This article introduces Tomcat articles, I am also ready to write an article introducing Jakarta. 4.1 What is Tomcat Tomcat is a standard implementation of Java Servlet 2.2 and JavaServer Pages 1.1 technology, which is a free software developed under Apache licenses. 4.2 Tomcat Download Download Downloads: http://jakarta.apache.org/downloads/binIndex.html 4.3 Tomcat and JSERV Difference JSERV is a Servlet API 2.0 compatible Servlet container developed by Apache. Tomcat is a completely rewritten Servlet API 2.2 and JSP 1.1 compatible servlet / JSP containers. Tomcat uses some code of JSERV, especially the Apache service adapter. 4.4 What is servlets, what is JSPS servlet provides a simple, consistent mechanism for web developers to extend the functionality of the web server, and interact with existing business systems. You can view the servlet as an applet running on the server. JSP technology is an extension of servlet technology, providing support for page creation of HTML and XML. Its web designer can be very easy to combine fixed or static template data with dynamic content. 5. Servlet / JSP / XML Frameworks Introduction Now, there are many Java-based open source web frameworks that make us more easily constructive web applications. I am here to make a simple introduction. 5.1 Cocoon - Based on XML-based Web Content Release

CoCoon is a content release framework written in 100% pure Java. CoCoon allows you to provide web content with the latest technology (DOM, XML, XSL) of W3C.

The new Cocoon mode fully separated document content, style, processing logic, allowing these three layers to be independently designed, created and managed, thereby reducing management overhead, strengthening the reuse of work, reducing development time.

Download address: http://xml.apache.org/cocoon

5.2 Xang - Rapid Development Dynamic web pages can integrate different data sources, allowing you to quickly develop data-driven, cross-platform web applications. The Xang architecture can complete data, logic, and representation. XANG is based on open industrial standards such as HTTP, XML, XSL, DOM, ECMAScript (JavaScript). Download address: http://xml.apache.org/xang 5.3 Slide - Content Management Framework SLIDE is a content management and integrated system, is a content management underlying framework. Slide provides a hierarchical structure that stores content to any, distributed data warehouse. In addition to this, Slide also integrates security, lock, content version, and other services. Download address: http://jakarta.apache.org/slide 5.4 Struts - JSP based on MVC design mode

Struts is an open source of the open source of the web application using Java Servlet / JavaServer Pages technology.

The Struts can develop an application architecture based on MODEL-View-Controller design mode.

Struts has the following main features:

1. Contains a Controller Servlet to send the user's request to the corresponding Action object.

2. JSP Free Tag Library and provides association support in the Controller Servlet to help developers create interactive form applications. 3. Provide a series of practical objects: XML processing, automatically handle JavaBeans property, international tips, and messages through Java Reflection APIs.

Download address: http://jakarta.apache.org/struts

5.5 JetSpeed ​​- Web-based component JetSpeed ​​is an open source software that implements Enterprise Information Portal. JetSpeed ​​can extract information from the Internet's vertical multi-resource to help users manage a large amount of data. These information can come from different content types, from XML to XMTP, to Icalendar's new protocols. Download address: http://java.apache.org/jetspeed 5.6 Turbine - WEB application development based on servlet

Turbine is a servlet-based Framework that enables experienced Java developers to quickly build web applications.

With Turbine, you can integrate existing template techniques (such as Velocity, Webmacro, Java Server Pages (JSP), FreeMarker, Cocoon by creating Screen of Templates using specific services.

Download address: http://java.apache.org/turbine

5.7 Various Framework comparison

In these Framework, I think Cocoon, Struts, and Turbine are better. These three have their faces, Cocoon is the best XML Framework, Struts is the best JSP Framework, Turbine is the best servlet framework.

6. JSP Framework - Struts Introduction Struts is the open source of the open source of the web application with Java Servlet / JavaServer Pages technology. The Struts can develop an application architecture based on MODEL-View-Controller design mode. Struts has the following main functions: 1. Contains a Controller Servlet to send the user's request to the corresponding Action object. 2. JSP Free Tag Library and provides association support in the Controller Servlet to help developers create interactive form applications. 3. Provide a series of practical objects: XML processing, automatically handle JavaBeans property, international tips, and messages through Java Reflection APIs. Struts is part of the Jakarta project, homepage at http://jakarta.apache.org/struts. Version 0.5 Download address: http://jakarta.apache.org/builds/jakarta-struts/release/v0.5 6.1 1 What is MVC mode. The MVC / View / Controller mode is a more design pattern that has been used abroad, as if the earliest is in Smaltalk. MVC includes three types of objects. Model is an application object, and the view is its representation on the screen, and the Controller defines the user interface to respond to the user input. 6.2 2, do you use MVC mode if all JSP applications? Not necessarily all JSP applications should be used in MVC mode. But for large applications, I think it is still using MVC mode. User interface interface is often mixed with these objects, while MVC separates them to improve flexibility and reuse. 6.3 3, can Struts do XML? What is the advantages compared to COCOON? Struts puts the main energy on the JSP. CoCoon is a professional-grade XML Framework. 7. Struts Installation 7.1 Installing Struts Required Software Java Development Kit - You need Download and Install 1.2 (or after) JDK. Download address: http://java.sun.com/j2se

Servlet Container - The usual choice is to download Tomcat (at least version 3.1, recommended using version 3.2). Download address: http://jakarta.apache.org/tomcat

Ant Build System - If you install the package through the Struts Source Code, you must download the 1.1 or later version of the Ant Build System. In your own web app, you also recommend using Ant to build your application. Download address: http://jakarta.apache.org/ant

Servlet API Classes - To compile Structs yourself, or the application uses Struts, you need a servlet.jar package that contains the servlet and JSP API objects. Most servlet containers (such as Tomcat) have come with this file. Otherwise, you must download: http://jakarta.apache.org/builds/jakarta-servletapi

XML Parser - Structs requires an XML processor compatible with Java API for XML Parsing (JAXP) specifications. I recommend using Xerces. Download address: http://xml.apache.org/xerces-j

Xalan XSLT Processor - If you construct your Structs system via the Structs source code, you must download and install 1_2_d01 or later version of the Xalan XSLT processor (Xalan in XERCES). This processor is used to convert XML-based Structs documents to HTML documents. 7.2 Constructing Structs via the source code

1. Download the Structs source code release package.

2. Set an ANT_HOME environment variable to point to your Ant directory.

3. Set the java_home environment variable to point to your JDK directory.

4. Set the servletapi_home environment variable, point to your servlet API directory (if your classpath already contains servlet.jar, you don't need to specify the directory)

5. Unpack the StruCTS source code package.

6. Go to the structs directory, run the following command:

./build.sh dist

This command will create a Struts binary release package, the directory is in ../ dist / structs (relative to your compilation directory).

7.3 Installing Structs with Binary Release Package with Struts

1. Download the Struts binary release.

2. Unpack the Struts binary release. (If you construct struts through the Struts source code, the result of Build is already unconnected Struts). The unproved Struts contains the following:

LIB / STRUTS.JAR - This file contains all Java objects for Struts. You need to copy it to your web-inf / lib directory for your web application.

LIB / STRUCTS.TLD - This is a "Tag Library Descriptor" file that describes the free TAG of the Struts library. Need to copy it to the web-INF directory of your web application.

WebApps / Struts-Documentation.war - This is a "Web Application Archive" file that contains all Struts documents. You can install it into the servlet container that supports Servlet API 2.2 or later (recommended using Tomcat).

WebAPPS / Struts-Example.war - This is a web application instance that extensively demonstrates many of the Struts. You can install it into a servlet container that is compatible with servlet2.2 or later and the JSP1.1 or later version of the servlet container (recommended using Tomcat).

WebApps / Struts-Test.war - This web application contains many TAG test web pages supported by Struts, which can be used as an example of using Struts Tag.

You can use the following steps to use struts in your own application:

1. Copy the Struts directory's lib / struts.jar to the web-inf / lib directory of the web application.

2. Copy the lib / struts * .tld of the struts directory to the web-inf directory of the web application.

3. Modify the web-inf / web.xml file of the web application directory, add a element to define the Controller Servlet, add a element to establish a correspondence between the URI request with the servlet. You can refer to the web-inf / web.xml file in the Struts example to learn more about grammar requirements.

4. Modify the web-inf / web.xml file for the web application directory so that the following Tag library definitions are included:

/web-inf/struts.tld

/Web-inf/struts.tld

/web-inf/struts-bean.tld

/web-inf/struts-bean.tld

/web-inf/struts-logic.tld

/web-inf/struts-logic.tld

5. Create a web-inf / action.xml file to define the Action mapping of your web app. You can refer to the Action.xml file in the Struts example to learn more about grammar requirements.

6. Add the following Tag library definition to the JSP page using the Struts Tag library:

<@ Taglib Uri = "/ Web-INF / STRUTS.TLD" prefix = "struts"%>

<@ Taglib Uri = "/ Web-INF / STRUTS-Bean.tld" prefix = "bean"%>

<@ Taglib Uri = "/ Web-INF / STRUTS-LOGIC.TLD" prefix = "logic"%>

7. Finally, don't forget to include the struts.jar file in the classpath when compiling the Java programs for your web application.

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

New Post(0)