![]() |
The Package Tool helps to build an archive of web components (WAR). The archive consists of servlets, JavaServer Pages (JSPs), taglibs, classes, XML deployment descriptor file, and related static content such as HTML and images. The properties that should be defined to specify the environment in which the web components run are:
Select Tools > Package > WAR > Add JSP/Servlet from the main menu.
A JSP is picked up from the web module with its complete path structure. All the servlets and JSPs on the active desk are available for selection. The JSPs are shown with the appropriate directories as stored under the desk. The selected file is added to the WAR. JSPs and servlets can also be added to the JSP/Servlets node in the WAR. To add a JSP or a servlet, click on the JSP/Servlet node to display all JSPs and servlets and their location:
Click Add to add all the available JSPs and servlets from the list or Right Click on the JSP/Servlets node in the WAR and select Add JSP/Servlet to add JSPs and servlets 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:
If the security is being checked inside a servlet code, the roles which the servlet looks for should be linked to the security roles defined at the WAR level.
Select Tools > Package > WAR > Remove JSP/Servlet from the main menu.
Click `Remove Servle ts' button to view a list of all servlets that can be removed. Select a servlet and click on OK to remove it from the WAR, permanently. To remove JSPs and servlets from a WAR:
The following sections describe the procedure to add classes, JARs, and files to a WAR.
Tools > Package > WAR > Add Classes
The "Add classes" 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. For 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
The dialog, Open, 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. "Add Files" dialog prompts for the following details to be filled before the files are added to the WAR:
Repeat the process as many times required. Clicking on OK adds all the files in the target directories. Consider this example:
To add *.gif image files from /im directory of a project to /images directory under the WAR:
/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:
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.
Filters can be associated with groups of Servlets and static content using url-pattern of filter mapping. Click on Add:
Click on the Taglib node in the Package Tool. This opens the Taglib Panel where the Taglib URI and the Taglib location can be added 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.
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:
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:
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:
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.
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:
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. Enter the following data:
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. A 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.
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 |
|