Understand the NetBeans New Web Application Wizard

For some reasons I have been forced to learn the NetBeans Web Project in detail :-) To create a Web project by using NetBeans, the first thing users will face is the New Web Application Wizard. I think it's not as easy as looking into my kid's new microscope manual. Therefore, I decided to collect the information that I got from various places into this guide. They are actually mainly from the NetBeans JavaHelp related to this wizard.

Here it is!

New Project Wizard: Choose Project

You use the New Project wizard to create a new IDE project.

To open the New Project wizard, choose File > New Project (Ctrl-Shift-N). Select a template category and a project template and click Next.

For each project category, there are two types of project templates:

  • Standard templates. Templates in which the IDE controls all source and classpath settings, compilation, running, and debugging. Standard project templates can contain one or more source folders and optionally one or more JUnit test folders.

    Source Folders

    In standard projects, you can have multiple source folders and multiple JUnit test folders for each J2SE, web, and EJB project. A single source folder cannot, however, be added to more than one project. If you need a source folder to be part of several projects, you should create a separate project for the source folder and add it to the classpath of each of your projects.

    Project Settings

    When you create a project from a standard project template, the IDE generates an Ant script that controls all aspects of program compilation, execution, and debugging.

    You can set basic project settings in the Project Properties dialog box by right-clicking a project node in the Projects window and choosing Properties. All changes are immediately registered in the project's Ant script. You can also set more complex options by editing the project's Ant script and properties file directly.

    The Project Folder

    Each standard project has a project folder where the IDE stores the Ant script, project metadata, and output folders. In projects with existing sources, you can place the project source directories in the same location as the project folder or in a separate location. In empty projects, the source root is always in the same location as the project directory.

    The following table lists the contents of a project folder:

    Item Description
    build.xml The build script called by the IDE. This build script only contains an import statement that imports targets from nbproject/build-impl.xml. Use the build.xml to override targets from build-impl.xml or to create new targets.
    nbproject The directory that contains the project Ant script and other metadata. This directory contains:
    • build-impl.xml. The IDE-generated Ant script. You should never edit build-impl.xml directly — always override its targets in build.xml.
    • project.properties. Ant properties used by the IDE to configure the Ant script. Although you can edit this file manually, you generally do not need to, as it is automatically updated by the IDE when you configure the project's properties.
    • project.xml and genfiles.properties. IDE-generated metadata files. Although you can edit project.xml manually, for standard projects you generally do not need to. You should never edit genfiles.properties .
    nbproject/private The directory that holds properties that are defined for you only. If you are sharing the project over VCS, any properties you define in private.properties are not checked in with other project metadata and are applied only to your installation of the IDE.
    build The output directory for compiled classes.
    dist The output directory of packaged build outputs (JAR files and WAR files). Standard Java projects produce one build output per project. The dist directory also contains generated Javadoc documentation.

     

  • Free-form templates. Templates in which your own Ant script controls all classpath settings, compilation, running, and debugging. The settings you configure when creating the project are used to tell the IDE how your Ant script manages your source code and must match the settings in your Ant script.

    Free-form projects can contain as many source folders as your Ant script is configured to handle. If your Ant script does not contain targets for all IDE actions, like debugging and running your project, you can easily write Ant targets for these actions.

    Source Folders

    Free-form Java projects can contain multiple source folders. The classpath relationships and handling instructions for your source directories must be handled in your Ant script.

    Project Settings

    In the project's properties, you declare the source folders, classpath, and output files for your project. Each source root can have a unique classpath and output file. These settings do not affect the actual contents or classpath of your application. The settings only tell the IDE how to handle the code. For example, the classpath settings tell the IDE which classes to make available for code completion.

    IDE Commands and Ant Targets

    In free-form projects, the IDE relies on your Ant script to provide targets for all IDE actions, such as running, debugging, and generating Javadoc. If your Ant script does not contain targets for these commands, the commands are disabled.

    You can easily write debug targets in your Ant script or in a supplementary Ant script. You can also add a shortcut to any of your Ant script's targets to the contextual menu of your project's node in the Projects window.

    For a full guide to configuring free-form projects, see:

    http://www.netbeans.org/kb/41/freeform-config.html

     

New Web Application Wizard: Name and Location

The New Web Application wizard creates a new standard project containing an empty web application. You open the New Web Application wizard by opening the New Project wizard and selecting the Web Application template from the Web category.

In the Name and Location page, you have to set the following properties:

  • Project Name. Specifies the display name of the project. This name is also used to create the project folder and the context path.
  • Project Location. Specifies the location where you want to store the project metadata and source code.
  • Project Folder. Specifies the folder where you want to store the project metadata and source code. The folder is a concatenation of the project location and the project name.
  • Source Structure. Specifies how your web application will be structured.

    Web application source files can be structured according to one of the following two recommendations. The recommendations are intended to assist you with organizing the files and directories associated with an application project in a logical fashion. When you create a web application, you must choose according to which recommendations your sources are to be structured:

    Java BluePrints

    Jakarta


    • Java BluePrints. The Java BluePrints Project Conventions specify recommended conventions for structuring enterprise applications or web applications.

      About Enterprise Applications

      An enterprise application is a collection of EJB modules and web application modules that are configured to work together when deployed to a J2EE application server. The enterprise application contains information about how the modules work with each other.

      The enterprise application also contains information about how the modules work with the application server to which the enterprise application is deployed. For example, if any entity beans use container-managed persistence, the enterprise application tells the J2EE application server what transaction services are needed.

      An enterprise application has no source files of its own. It only contains deployment descriptors and other configuration files. At compile time, the archive files (JAR files and WAR files) for each of the enterprise application's modules are built and assembled into one Enterprise Archive (EAR) file. This file is deployed to the J2EE application server.

      About Web Applications

      A web application is an application written for the Internet, including those built with Java technologies such as JavaServer Pages and servlets, as well as those built with non-Java technologies such as CGI and Perl.

      A web application roughly corresponds to the J2EE term web application module. This is a deployable unit that consists of one or more web components, other resources, and web application deployment descriptors, contained in a hierarchy of directories and files in a standard web application format.

      About Creating Web Components

      A web component is an object that provides services in response to requests, within the context of a web application.

      The main web components are as follows:

      • JSP pages and JSP segments.
      • Applets.
      • Java class files for the servlets, filters, and listeners.
      • Java class files for the classes that the JSP pages, applets, servlets, filters, and listeners depend on such as JavaBeans components. Optionally, you can package these classes as library JAR files.
      • Static documents, such as HTML files, images, sound files, and so on.
      • Tag files and tag segments.
      • Custom tag libraries with tag library descriptor files (TLD files). TLD files are typically included in the tag library's JAR file.

      Before you can create a web component, you must create a web application to contain it.

      About Creating Web Applications

      Web applications have a defined folder structure. A web application is usually packaged and deployed as a web archive (WAR) file, although a web application does not always have to be packaged in order to be deployed.

      A web application must contain a deployment descriptor file ( WEB-INF/web.xml). A web application can contain one or more web components.

      Configuring Web Application Deployment Descriptors

      Deployment descriptors are XML-based text files whose elements describe how to assemble and deploy a module to a specific environment. The elements also contain behavioral information about components not included directly in code.

      For web applications, there are three types of deployment descriptors:

      • web.xml. The general web application deployment descriptor that configures deployment settings for components belonging to a web application, such as servlets and JSP files.
      • sun-web.xml. The server-specific deployment descriptor that configures deployment settings for the Sun Java System Application Server.
      • context.xml.The server-specific deployment descriptor that configures deployment settings for the Tomcat Web Server.

    • Jakarta. The Jakarta recommendations specify recommended conventions for structuring web applications.

    Web Root

    The web root (document base) folder corresponds to the highest level of the project. The illustrations show the JSP files in both the root folder and the WEB-INF folder. You cannot directly access JSP files that are under the WEB-INF folder. These JSP files can be accessed only by another JSP file or by a servlet, such as by a forwarding request.

    TLD files are typically packaged in the tag library's JAR file. If not, place the TLD file in the WEB-INF folder or subfolder.

    \*  Note that the Tomcat Web Server does not support .zip files in the WEB-INF/lib folder.

     

  • Add to Enterprise Application. Lets you specify an existing enterprise application to which the web application will be added as a module. If you do not add it here, you can do so later by expanding the enterprise application project node and right-clicking the J2EE Modules node.
  • Server. Specifies the web application's server. Only servers that are registered with the IDE are available to be selected here:
    • For versions of the IDE that are bundled only with the Tomcat Web Server, the Tomcat Web Server is automatically registered in the IDE.
    • For versions of the IDE that are bundled with both the Tomcat Web Server and the Sun Java System Application Server, both servers are automatically registered in the IDE.
  • J2EE Version. Specifies the J2EE level against which your web application will run.
  • Context Path. Specifies a way to distinguish resources in one web application from resources in others that are deployed on the same server instance. The context of an application determines the URL namespace of the contents of the web application. When a web application's context property value is set, you access the web application at http://hostname:port/context/servlet_or_jsp. For example, with the property value set to /HelloWeb, you access the web application at http://hostname:port/HelloWeb/index.jsp.
  • Source Level Recommendations. One of the following checkboxes will appear if JDK 1.5 is set as the default platform in the Java Platform Manager. The J2EE 1.4 and J2EE 1.3 specifications do not recommend JDK 1.5. Therefore, if you want to create a portable application, select the appropriate checkbox:
    • Use JDK 1.4 and Set Source Level to 1.4. This checkbox appears if JDK 1.4 is available in the Java Platform Manager. Select this checkbox to set both your JDK level and your source level to 1.4.
    • Set Source Level to 1.4. This checkbox appears if JDK 1.4 is not available in the Java Platform Manager. Select this checkbox so that at least your source level is set to 1.4.
  • Set as Main Project. Sets the newly created project as the main project.

    Setting the Main Project

    When you develop a large application consisting of numerous source directories, it is common to split up your code into separate projects. Of these projects, one is typically the entry point for your application and contains the application's main class.

    To tell the IDE which of your projects is the main entry point for your application, you set one project to be the main project. The IDE provides commands that act on the main project. For example, running the Build Main Project command builds both the main project and all of its required projects, thereby ensuring that you all of your compiled classes are up-to-date. Only one project can be the main project at any time.

If you click Next, you can let the IDE provide your application with all the source files and libraries needed to work with JSF, Struts, or both frameworks. If you click Finish, the project is created on your computer and opened in the IDE. You can view its logical structure in the Projects window and its file structure in the Files window.

 

New Web Application Wizard: Frameworks

In the Frameworks page, you choose one or more frameworks that you want to use to provide a structure for your web application.

Choose one or both of the following:

  • Struts 1.2.7. Specifies that you want the IDE to provide the Struts 1.2.7 libraries and create the following files for your application:
    • welcomeStruts.jsp
    • struts-config.xml
    • tiles-defs.xml
    • validator-rules.xml
    • ApplicationResource.properties
    For details, see:

    http://struts.apache.org/

  • After you click OK, you can set the following properties:

     

  • Java Server Faces. Specifies that you want the IDE to provide the JSF 1.1 libraries and create the following files for your application:
    • welcomeJSF.jsp
    • faces-config.xml
    For details, see:

    http://java.sun.com/j2ee/javaserverfaces/

    After you click OK, you can set the following properties:

    When you click Finish, the project is created on your computer and opened in the IDE. You can view its logical structure in the Projects window and its file structure in the Files window.

     

Comments:

I have disabled the features of create as main class and set as main project in my new project window. Now when I open the window again, my netbeans application is by default moving into java web application and also not showing me the option of the main class features. Can you help me in this regard?

Posted by Manikandan on May 24, 2008 at 02:39 AM PDT #

nothing

Posted by guest on July 22, 2008 at 06:52 PM PDT #

please send me where to start my coding for building a web based project to run on net beans.And i already have a web based project and how to run it i.e how can i see the browser page of that project please reply to my mail its urgent

Posted by sreenivas333 on February 18, 2010 at 10:14 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

poting

Search

Top Tags
Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today