Practice JSP in NetBeans 4.1

Source: Internet
Author: User
Tags constructor tomcat netbeans

First, install the software

You need to install the following software on your computer:

NetBeans IDE 4.1
Java Standard Development Kit (JDKTM) 1.4.2 version or version 5.0

Second, the Web server

NetBeans IDE 4.1 bundled with Tomcat

Third, create a new WEB application project
1, select "File" > "New Project". Under Categories, select Web. Under Projects, select Web Application, and then click Next.
2, under the "project name" input testjsp. Note that the context path is/testjsp.
3, change the "project location" to D:\APP.
4, select the server you want to deploy the application to. Bundled Tomcat (5.5.7)
5. Leave the Set as main item check box selected. Click Finish.

The IDE creates the D:/app/testjsp project folder. The project folder contains all the source and project metadata, such as the project's Ant build script. The Helloweb project opens in the IDE. You can view its logical structure in the Projects window and view its file structure in the Files window.

Iv. creating Java Packages and JavaBeans components

1, expand the Helloweb project node and the "source package" node. Note that the source Packages node contains only one empty default package node.
2. Right-click the Source Packages node and select New > Files/folders. Under Categories, select JavaBeans object. Under File types, select JavaBeans components, and then click Next. Enter Namehandler in the Class Name text box, and then enter java3z.com in the package combo box. Click Finish.

V. Editing JavaBeans components

1, expand the Namehandler.java node, and then double-click the Namehandler class node. In the source editor, delete the following class declarations section:
Extends Object implements Serializable

2, expand the Namehandler class node and the "Fields" node. The system provides three default fields. Right-click the Prop_sample_property field and choose Delete from the context menu. Perform the same action on the other two fields. Note that in the source editor, lines of code that use these delete fields are underlined in red.

3, expand the Methods node, and then remove all default methods.
In the source Editor, type the following code in line 16th immediately below the class declaration: String name;

4, expand the Constructors node and double-click the Namehandler constructor. Edit the Namehandler () constructor in the source editor by propertysupport the default code in line 18th = new Propertychangesupport (this);) Replace with the following:
name = NULL;

5. Press Alt-shift-f in the source editor to update the import statement so that the code specifies only the statements that you want.

6, rename the field
Right-click the word name in the field declaration on line 15th and choose Refactor > Rename.
In the New Name field, type username. Then click Next.
The refactoring window shows in advance all references that will be changed to point to the new named field. Double-click any reference to jump to its location in the source editor. check box to indicate which references will be refactored.
Click "Refactor". All selected references to the field will be renamed.

7. Generate acquisition method and Setup method
Right-click the Word username in the field declaration on line 15th and choose Refactor > Encapsulate fields. Click Next to run the command with the default option.
Click "Refactor". The Fetch method and set method are generated for the username field.

The JavaBeans component should now look like the following:

Package Org.me.hello;
public class Namehandler {
Private String username;
Public Namehandler () {
Setusername (NULL);
}
Public String GetUserName () {
return username;
}
public void Setusername (String username) {
This.username = Username;
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.