|
The Package Tool helps in building an archive (WAR) of Web components. The archive consists of Servlets/JavaServer Pages, Taglibs, classes, the XML deployment descriptor file, and related static content like HTML and Images.
The following properties have to be defined to specify the environment in which the Web components run:
Tools > Package > WAR > Add JSP/Servlet
The JSP file is picked up from the Web Module with its complete path structure. All the Servlets and JavaServer Pages on the active Desk are shown for selection. The JSP Pages are shown with the appropriate directories as stored under the Desk. The selected file is added to the WAR:- the .jsp file is added if the selected item is a JSP, and the servlet class file is added if the selected item is a servlet.
JSP Pages and Servlets can also be added to the JSP/Servlets node in the WAR. Clicking on this node displays all the JSP Pages and Servlets it contains and the location of the file. Clicking on Add allows you to add all the available JSP Pages and Servlets from the list.
Right Clicking on the JSP/Servlets node in the WAR > Add JSP/Servlet also allows you to add JSP Pages and Servlets to the WAR.
After the JSP/Servlet has been added to the WAR, a node for the added JSP/Servlet is created under the JSP/Servlets node in the tree. The following information is displayed in that node:
JSP/Servlet Name The name of the JSP or the Servlet, which has been added to the WAR is displayed in this field
Display Name The name of the JSP or Servlet, used for viewing in the tree node.
Class Name/JSP File Name Depending on whether the JSP or the Servlet was added to the WAR, the JSP File Name or Class Name is displayed.
Initialization Parameters This section is used to add the initialization parameters for the JSP or the Servlet.
Servlet initialization parameters can be specified here so that the servlet can have access to the deployment specific information at run time.
If the security is being checked inside the servlet code, then the roles, which the servlet looks for, have to be linked to the security roles defined at the WAR level.
Tools > Package > WAR > Remove JSP/Servlet
Clicking on the Remove Servlets button, prompts you with a list of all the Servlets that can be removed. Selecting a Servlet and clicking on OK removes it from the WAR permanently.
JSP Pages and Servlets can also be removed from the JSP/Servlets node in the WAR. Clicking on this node displays all the JSP Pages and Servlets it contains and the location of the file. Clicking on the Remove button allows you to remove the selected JSP/Servlet from the WAR.
Right Clicking on the JSP/Servlets node in the WAR also allows you to remove JSP Pages and Servlets from the WAR.
Tools > Package > WAR > Add Classes
The Select the Files to Add dialog prompts for the directory where the utility classes are stored. Check the Recurse Folders option to run through all the subdirectories and add the matching files.
The Regular Expression field is by default *.class (all class files). Change the type to any other regular expression using "*." as the wild card prefix. The extension should always be .class.
Example
It is possible to choose all .class files whose names start with CUST. Class files are added to the following directory in the WAR: WEB-INF/classes
Tools > Package > WAR > Add JAR
"Open" dialog prompts for the JAR. The selected .jar is added to the following directory under the WAR: WEB-INF/lib. The JAR file can either be a Java archive file or a taglib JAR. Java archives containing supporting classes should be included in the Web archive.
Tools > Package > WAR > Add Files
This command helps add the files present in the WAR. "Select Files to Add" dialog prompts for the following details to be filled before the files are added to the WAR:
Base Directory Base Directory is the directory where all the files are located.
Recurse Enabling this option browses through the sub-directories and adds the matching files. This option is by default enabled.
Filter Type the filter to be implemented while searching for the files. Once the filter has been decided click on Search. This filters all the unwanted files and displays a list of all files available with the specific requirements.
Target Directory The folder under which the files selected are to be added. This is optional. Target Directory is appended to the path by which the files get added. Not selecting a target directory adds the files under the folder where the right click was implemented.
Add Selecting all the files to be added and clicking on Add places the selected files in the Selected Files box.
Repeat the process as many times required. Clicking on OK adds all the files in the target directories.
Example
To add *.gif image files from /im directory of a project to /images directory under the WAR:
Point to the [project]/im directory in the file system
Set Regular Expression to *.gif
Set Path to /images
If the files exist as [project]/im/abc.gif and [project]/im/docs/123.gif then they are added as:
/images/abc.gif
/images/docs/123.gif
(assuming that the Recurse Folders option is ticked in the Select the Files to Add dialog box).
Tools > Package > WAR > Add Filter
This command allows the user to add filters to the WAR. Servlet filters, a new type of Web component designed for implementing multiple content transformations; and, a new, alternate XML representation of JSP content, which enables use of standard XML tools and services for creating and manipulating JSP pages.
After the filter has been added to the WAR, a node for the added filter is created under the Filters node in the tree. The following information is displayed in that node:
Filter Name The fully qualified filter name, which is used to map the filter to a servlet or URL.
Display Name The name of the filter, which is used to display in the tree node.
Initialization Parameters This section is used to add the initialization parameters for the filter.
After the filter has been added to the WAR, use the Filter Mapping node in the tree to define Servlets and static resources in the web application to which the filter is to be applied.
Clicking on the Add button adds the mapping where filters can be associated with groups of Servlets and static content using the url-pattern style of filter mapping:
URL Pattern/Servlet This field displays the url pattern matching filter mappings and the Servlets in the WAR.
Filter Name This field displays the fully qualified filter names in the WAR, which are to be mapped.
Click on the Taglib node in the package tool. This opens the Taglib Panel where both the Taglib URI and the Taglib location can be added here using the Add button. To delete the Taglibs that have been added, select the taglibs to be deleted and click on Delete.
War file on the Desk > Right Click > Update
Updates the JSP files, static content like HTML, images, all classes, and the Servlet classes in the WAR. JSP Pages and Servlets are always picked up for updation from their appropriate location. Other files like HTML, and images are stored with their absolute paths and therefore may not be located if they have been moved from their original location.
These files that are stored with their absolute paths, may not be located if they have been moved from their original location.
A time stamp based update is used to update the WARs, which makes the updating faster in most scenarios.
Updating a Web archive comprises first locating the files on the desk and the file-system and if they have been changed, the latest files are added to the WAR. Whenever a Servlet or jsp or tag is added to a WAR, the web-module it belongs to, is saved in META-INF/update.props. A log of update operations is available on the Update Tab in the Output area of Studio. This log shows normal messages in black, updating messages in green and any failures or errors in red. Usually a remedial measure is also provided in the case of errors. A progress bar indicates the progress of the operation.
Choosing Update brings up a dialog box with a progress bar. All the updating messages are displayed here. To stop updating the WAR, click on Cancel. Studio in the meantime can be used as usual but the WAR file being updated cannot be opened. If the package names of the above are changed, then the WAR is not updated.
For a file to be located correctly on the desk, it should have been added to WAR, else it cannot be located. This scenario is most likely to happen when the WAR was not created using Pramati Studio 3.0. Note that WARs created using earlier versions of Pramati Studio also do not have this information and will not get updated in version 3.0. This information might also get out of synch with the desk's state if you move the file from the original Module where it was located. The solution is to re-add the entry into the WAR. This will re-create the update information.
Select the EJB References tab in the References panel for declaring the reference to an enterprise bean's home. The references added here are used to specify all the Enterprise JavaBeans that the Servlets/JavaServer Pages in this WAR lookup for.
Looking up for the bean inside a servlet using a "logical" name makes the code independent of the actual JNDI (Java Naming and Directory Interface) name by which the bean is bound.
To do this, the following declarations are to be specified:
Name Enter the name of the EJB reference to be added in this field. The name must be unique within the WAR.
Type Choose the expected type of the referenced enterprise bean from the combo box. The bean type can be either Session or Entity.
Remote Reference After selecting the name of the bean to be looked up, select the Remote Reference to specify the Home Class Name and Remote Class Name. The user can either select Remote Reference or Local Reference.
Local Reference After selecting the name of the bean to be looked up, select the Local Reference to specify the Home Class Name and Remote Class Name.
JNDI This field appears only for web.xml file and does not appear in the WAR. The JNDI name is used in the EJB Reference to specify that an EJB Reference is linked to an EJB in an encompassing J2EE application package.
The value of the EJB Link must be the EJB name of and EJB in the J2EE application package. Selecting the references automatically selected JNDI name for the reference to be created.
Resource References are used in the WAR to declare the web application's reference to an external resource. Use the Add button to add a new resource to the WAR. Once the resource reference gets added to the WAR, enter the following information:
Reference Name Enter the name of the resource reference in this field.
Type Select from the dropdown combo box or enter the Java class of the resource reference.
Authentication Select the authentication as either Container or Application from the dropdown combo box. Specifying the authentication indicates whether the application component code performs resource sign-on programmatically or whether the container signs onto the resource based on the principle mapping information provided at the time of deploying the application.
Sharing Scope Selecting the sharing scope as Shareable or Unshareable indicates whether the connections obtained through the resource reference can be shared or not.
Resource Environment References are used to declare the web application's reference to an administered object associated with a resource in the web application's environment. Use the Add button to add a new resource environment reference to the WAR. Once the resource environment reference gets added to the WAR, enter the following information:
Reference Name Enter the name of the resource environment reference in this field. The name must be unique in the WAR.
Type Enter the type of a resource environment reference, or select from the list in the combo box. It is the fully qualified name of a Java language class or interface.
Use the Environment Entries node in the tree to declare the environment entry of the application. Use the Add button to add the entry in the WAR.
Name Enter the name of the application environment entry in this field.
Value Enter the value here.
Type Select the fully qualified Java type of the environment entry value that is expected by the application code in this field, from the dropdown combo box.
This is used to configure the authentication method and the realm name that should be used for this application, and the attributes that are needed by the form login mechanism.
Choose from the following options:
Basic Select Basic as the authentication type if the authentication mechanism for the WAR has to be set as BASIC.
Form Select Form as the authentication type if the authentication mechanism for the WAR has to be set as FORM.
None Choose this option if your application does not require login
Listeners are classes that implement one or more of the servlet event listener interfaces. The Listener classes must be registered as a web application listener bean. Use the Add button to add the Listener Classes to the WAR. After a new listener is added, enter the value as the fully qualified class name of the listener class.
Context Parameters are used to declare the web application's Servlet Context Initialization Parameters. Use the Add button to add new context parameters to the WAR.
Parameter Name Enter the name of the context parameter in this field.
Parameter Value Enter the value of the parameter.
A security role is a semantic grouping of permissions that a given type of user of the application must have in order to successfully use the application. The application assembler defines Security Roles for a WAR composed of one or more Web components.
A security role needs a name (example: administrator) and a description (example: full access). Defining more than one role is possible.
The application assembler defines Security constraints using these roles declaratively in the deployment descriptor.
At the deployment stage the deployer assigns principals, defined in the target operational environment, to the security roles defined here inside the WAR.
Security Constraint > Right Click > Add Security Constraints
This adds a new security constraint to the WAR. For a security constraint to be added, login configuration needs to be defined first. A WAR can contain multiple security-constraints.
Click on the New button on the security constraint panel to create a new resource collection. Identify the resources that are to be secured and whose access has to be restricted. Group these "related" resources (with respect to security) into a resource-collection.
The resources can be servlets, JavaServer Pages, HTMLs, or gif images. Specify the resource as a URL pattern. For example: /admin/*
Security Constraints > Security Constraint > Right Click > Remove
Security constraints that were already created can be removed. It deletes all the resource collections of that constraint.
For a client to invoke a servlet, a URL pattern is required. Servlets are added to the WAR file with names unique to the archive. To invoke a servlet as a response to a URL request, a Servlet Mapping is created during WAR assembly. Such a mapping will specify a URL pattern and map it to a deployed servlet. An URL pattern can be one of the following types:
String beginning with '/' and ending with a '/*' used as path mapping.
Example 1
/catalog/*
String beginning with '*.' used as an extension mapping.
Example 2
*.jsp
Any other string used as an exact match.
Example 3
/user/profile/show
The Server provides a default mapping for all the servlets in the WAR file, and therefore usually no mapping is required.
Example 4
If a servlet uses a servlet class file company.servlets.DummyServlet, then a request for: http://127.0.0.1:8181/module/company/servlets/DummyServlet
is automatically routed to the servlet. If the servlet uses a JSP, login.jsp. then a request for: http://127.0.0.1:8181/module/login.jsp is automatically routed to the JSP. Here module is the context root.
*.jsp is implicitly mapped to the JSP engine. All requests ending with .jsp are routed to the JSP engine unless over-ridden by another mapping.
This panel allows the user to map between an extension and a MIME type. Use the Add button to add an instance where the extension maps to a MIME type and the Delete button to delete the mapping instance. The Extension is a string, which describes an extension. Examples of extension are txt, doc etc. an example of a MIME type is text/plain.
The list of ordered welcome files are added here in this panel. Welcome files are those files, which are used as default introductory files when an application is run.
Use the Add button to add a welcome file to the list. Once it is added, the name appears as Welcome File, which on a double click displays all the files (in a combo box) in the WAR file. Select one of those files. To change the order of the welcome files list, use the up arrow and down arrow buttons. To remove a file from the list, use the Remove button.
A Web Module can be configured such that a specified error file is sent to you whenever there is a certain exception or response status. This helps in centralized error handling and logging. You can specify this information using Error File Mapping. There are two ways of doing this:
Tools > Package > War > Save
Saves the open WAR
Tools > Package > War > Close
Saves and closes the open WAR.
Tools > Package > WAR > Revert
Revert the WAR to last saved state.
The web.xml of the WAR can be viewed by clicking on the XML node.
| Pramati Technologies © Copyright |
|