Hitachi

uCosminexus Application Server System Setup and Operation Guide


L.7 Sample program of Web application

Sample program of Web application sample program is stored in the following directory:

Cosminexus-installation-directory\CC\examples\webapps

Following is the overview and execution procedure of the sample program:

Organization of this subsection

(1) Overview of the sample program of Web application

You can use the servlet conforming to the specifications of Servlet 2.5 and JSP sample program as a sample of Web application. This section describes the prerequisites, types of sample programs and configuration of the sample programs.

(a) Prerequisites

The following are the prerequisites of the sample program of Web application:

  • The version of Web application must be Servlet 2.5.

  • You must run Web application in the J2EE server mode.

Additionally, the sample program of Web application uses JSTL 1.2. You must set a class path in usrconf.cfg in order to use JSTL 1.2.

(b) Types of sample programs

The following are the types of the provided sample programs:

Servlet
  • Display of "Hello World"

  • Display of HTTP request information

  • Display of HTTP header

  • Display of HTTP request parameter

  • Cookie operation

  • HTTP session operation

JSP
  • Expression Language#1

  • Simple tag handler, JSP fragment

  • Tag file#1

  • JSP of XML syntax#1#2

  • Other functionalities mentioned in JSP 2.0 specifications

  • Functionalities mentioned in JSP 1.2 specifications

#1

This sample program uses JSTL.

#2

This sample returns the execution result in SVG data format. You must have a SVG compliant browser to display the data in SVG format.

(c) Configuring the sample programs

You can use the sample programs of Web application as is as an exploded archive format. The following figure shows the configuration under the Cosminexus-installation-directory\CC\examples\webapps:

Figure L‒42: Configuration under the webapps directory

[Figure]

In the execution procedure of the sample programs of Web application explained hereafter, the webapp directory under the Cosminexus-installation-directory\CC\examples is mentioned as webapps directory.

(2) Execution procedure of the sample programs of Web application

The following procedure describes the execution procedure of the sample program. The following functionalities are used in this procedure:

(a) Compiling sample programs

Compile the servlet, filter and listener of Web application; Java source file of JavaBeans and the JSP file; using the batch file (compile.bat) provided in the sample.

Java source files such as servlet and filter use javac command , and the cjjspc command is used for compiling the JSP files.

(b) Setting the J2EE server

See Appendix L.1(1) Setting the J2EE server.

(c) Customizing the J2EE server

See Appendix L.1(2) Customizing the J2EE server.

(d) Starting the J2EE server

See Appendix L.1(3) Starting the J2EE server.

(e) Registering users and roles

Register the users and roles by using the batch file (setupUsers.bat) provided in the sample. This batch file registers the users and roles for the J2EE server with J2EE server name "MyServer".

Following process is executed by this batch file:

  1. The following users are registered on executing the cjaddsec command:

    User 1: User name "user1", password "passwd1"

    User 2: User name "user2", password "passwd2"

  2. Roles "role1" and "role2" are registered on executing the cjaddsec command.

  3. The following mappings are registered on executing the cjmapsec command:

    Mapping 1: Role "role1" and user "user1"

    Mapping 2: Role "role2" and user "user2"

The user name and password registered here are used in the "Security" on the JSP sample page.

(g) Executing the application

Start the browser, specify the following string in the URL and access the top page of the Web application.

http://Machine-name/examples

When you customize the port number, specify ": Port-number" after Machine-name.

Specify the following when you access from the host on which the J2EE server is started.

http://localhost/examples

The following top window is displayed when the access is successful:

Figure L‒43: Execution procedure of the sample program of Web application

[Figure]

(h) Undeploying the application

See Appendix L.1(6) Stopping and deleting the application.

(i) Stopping the J2EE server

See Appendix L.1(7) Stopping the J2EE server.