MediaWare User Guide

fortunabrontideInternet και Εφαρμογές Web

13 Νοε 2013 (πριν από 3 χρόνια και 5 μήνες)

91 εμφανίσεις






MediaWare User Guide

Web Application Server for E
-
Commerce,
Database and Document Management


Version 3

Last Modified:
Wednesday, November 13, 2013
OpenAsia Solutions






MediaWare

Overview

MediaWare is the leading platform for
development, delivery and management of
enterprise network applications. It can be used to deliver integrated Internet, Intranet
and extranet applications.

The MediaWare application server, based on industry
-
standards Java, integrates with
a variety of sys
tems and applications, enabling delivery of applications that draw from
multiple sources of data within your organization. The user interface can be presented
in an HTML, Java or XML client.

Designed from the ground up for the Internet, MediaWare enables b
usiness to puruse
a network application strategy that leverages on Java
-

builds on any existing systems,
and delivers on any client strategy. A key strength of MediaWare is that it seamlessly
pulls together all the elements required to rapidly leverage th
e power of the Internet for
business.

MediaWare Application Server is a high
-
performance, Java
-
based application server.
It integrates HTML and server
-
side logic via customized MediaWare tags, and can
access remote RDBMS to create an Internet application.

Key MediaWare Application Server features:



Java
-
based, multi
-
threaded distributed architecture



Full Java 1.1 and 2 support



Caching of templates and data source connections



Firewall compatibility for HTML or Java pages



Connectivity to any JDBC or ODBC
-
comp
liant database



Support PDF extraction, injection and printing



Support RealMedia processing



2

Requirement

JDBC

JDBC allows MediaWare to connect to a wide range of relational databases; all you
need to do is to supply the JDBC drivers.

There are four types of

JDBC drivers:

1.

The JDBC
-
ODBC Bridge provides JDBC access via most ODBC drivers. Note
that some ODBC binary code and in many cases, database client code must be
loaded on each client machine that uses this driver.

2.

A native
-
API partly
-
Java driver converts JD
BC calls into calls on the client API for
Oracle, Sybase, Informix, DB2, or other DBMS.

3.

A net
-
protocol all
-
Java driver translates JDBC calls into a DBMS
-
independent net
protocol, which is then translated, to a DBMS protocol by a server. This net server
mid
dleware is able to connect its all Java clients to many different databases. The
specific protocol used depends on the vendor. In general, this is the most JDBC
alternative. It is likely that all vendors of this solution will provide products suitable
for
Intranet use.

4.

A native
-
protocol all
-
Java driver converts JDBC calls into the network protocol
used by DBMS directly. This allows a direct call from the client machine to the
DBMS server and is a practical solution for Intranet access. Since many of these
protocols are proprietary, the database vendors themselves will be the primary
source for this style of driver.

Java 1.1 comes with a free JDBC driver called
JDBC
-
ODBC Bridge

that allows
connection to any ODBC drivers. You can get more information on vari
ous JDBC
drivers at:
http://java.sun.com/products/jdbc/jdbc.drivers.html

Client

The client requirement is simple
-

all you need is a machine that is able to run an
HTML browser. No other setup is required. Windows machines and Macintosh
computers are fully

supported. Java support is not necessary, but JavaScript support
is recommended.

Web Server

Which web server is supported?

MediaWare can be deployed on any web server machine that supports Java servlets.
This includes Windows, UNIX, OS/2 and Macintosh mac
hines. Web server software
that are supported includes:



Apache



3



Microsoft Internet Information Server (IIS) and Personal Web Server



O'Reilly & Associates WebSite Pro



Netscape FastTrack and Enterprise Servers



StarNine WebSTAR



Apple AppleShareIP



Social Engi
neering Quid Pro Quo 2



Tenon WebTen



Live Software JRun



vqSoft vqServer.

MediaWare is installed on a web server. The web server is typically running on
different machine from the database server.

How do I enable the web server to support servlet?

Your web
server has to be able to support servlet before you install MediaWare. Some
web servers, like Sun Java Web Server, O'Reilly & Associates WebSite Pro, StarNine
WebSTAR, Live Software JRun and vqServer, have build
-
in servlet support. For
others, you will nee
d a servlet engine like JRun (which can be used with other web
servers) or New Atlanta's ServletExec to work together with the web server.

You can get more information on the servlet
-
enabled web servers at:



Java Web Server:
http://jserv.java.sun.com/produ
cts/webserver/index.html



WebSite Pro:
http://software.ora.com



WebSTAR:
http://www.starnine.com



JRun:

http://jrun.com



vqServer:
http://www.vqsoft.com/vq/server/index.html

You can get the servlet engines at:



JRun:
http://jrun.com



ServletExec:
http://www.newa
tlanta.com



WebSphere Application Server:
http://www.software.ibm.com/webservers/appserv



4

Compatibility Issues

Although MediaWare can run on any web server that support servlets, it is not
possible to test on all possible combinations. At this moment, we hav
e fully tested
MediaWare to be running on the following environments:

Operating Systems


Web Server


Servlet Engine


Windows 95/98


JRun



JRun







vqServer


vqServer


Windows NT


Internet


JRun


Information


Server







Netscape


JRun

Enterprise

Serv
er


JRun



JRun


vqServer


vqServer


Mac OS 8.5


Quid Pro Quo


ServletExec


Solaris



Apache



WebSphere

Application








Server


HP/UX



Netscape


JRun





Enterprise





Server



Database Server

Database server may run on any machine that support

SQL v2.0 or later. It is typically
run on different machine from the web server.

You will need to install RMI
-
JDBC on this machine if you do not have a JDBC driver
that can access remote database. Look for the
RMI
-
JDBC Installation

chapter for
more detai
l.



5

MediaWare Installation

Installation of MediaWare

Your web server should be servlet
-
enabled. If it is not, download a copy of JRun and
follow the installation guide of JRun to enable your web server to run servlets.

Once your web server is able to run s
ervlet, copy all the MediaWare files provided into
a directory. In the example below, we are assuming you called the directory
mediaware
. Following the manual of the servlet engine, set the classpath to the
following files.


mediaware/


mediaware/pdf/


med
iaware/java/mail.jar


mediaware/java/activation.jar


mediaware/java/collections.jar


mediaware/java/rmijdbc.jar
(optional)

Set up a server alias
/mediaware

to the
mediaware

directory. This is
important
!
Without the server alias, MediaWare will not run prop
erly.

OpenAsia Solutions will provide you with a database key file that connect to a
particular database. You will be using the name of the file (without the
.key

suffix) to
access the database in MediaWare.



6

Testing of MediaWare

After copying, launch a br
owser and type
localhost/servlet/Framer

in the
location (URL) box. If MediaWare is installed properly, it should reports its version
number and other internal states of the program.

To test MediaWare running on a database, run the prober by calling it from

a browser
using the URL
localhost/mediaware/util/prober/
.

1.

Fill in the database key input field.

2.

Type one or more SQL statements in the SQL statements text area. If more than
one SQL statement is written, delimited them by semicolons.

3.

Click on the Post to
Framer button. If you can connect to the database, and the
SQL statements are valid, you should see the result on the screen.

Configure MediaWare

You can set up a file called
mwconfig.tx
t in the MediaWare directory to configure
the states of MediaWare when

it started. Here is a sample of
mwconfig.txt

file:

# Registration of customized tags definition file



register c:
\
user
\
limtc
\
mediaware
\
formtags.txt


# The path of the log file


logPath = c:
\
user
\
mwlog.txt


# The directory of the key files



keyDir = c:
\
u
ser
\
key
\


# Cache settings


tmpCache = false

dbCache = true


# Default variables


inbox = c:
\
user
\
limtc
\
oe2
\
inbox
\

outbox = c:
\
user
\
limtc
\
oe2
\
outbox
\



# Import configurations




import c:
\
user
\
oe2config.txt



import http://www.discvault.com/dvconfig.txt




7

You can register your own customized tags using the
register

keyword (refer to
section
Extending Mediaware
).

Setting the
logPath

allows you to output logged messages to a file specified by
logPath
. The default is
mediaware/mwlog.txt
.

Setting the
keyDir

all
ows you to locate the key files in that directory. The default is
the
mediaware/key/

directory.

You can set the state of the template caching and database caching in MediaWare. If
tmpCache

is true, then once the template is read into the MediaWare, it will

stays in
the memory until MediaWare shuts down. If
dbCache

is true, then MediaWare can
allowed multiple requests to use the same database connection, which will speeds up
the database access. The default for the caching are both false.

You can set default

global variables for MediaWare. These variables will be available
for all the templates used by MediaWare.

MediaWare can import configurations from other files using the keyword
import
. You
can import either from a file (full path must be specified) or an

URL (full URL must be
specified).

Troubleshooting

Is MediaWare installed properly?

Launch a browser and type
localhost/servlet/Framer

in the location (URL)
box. If MediaWare is installed properly, it should reports its version number and other
internal st
ates of the program.

If an error message occured, check whether the classpath is set properlly to the
directory containing MediaWare, and the
collections.jar

file (not the directory
containing it). For setting of classpath, check your servlet engine (or th
e servlet
-
enabled web server) documentation.

You should also remember to the server alias
/mediaware

for MediaWare. Consult
your web server manual for instructions to set up a server alias.

How do I know which version of MediaWare I am running?

Launch a br
owser and type
localhost/servlet/Framer

in the location (URL)
box. If MediaWare is installed properly, it should reports its version number and other
internal states of the program.

MediaWare is running fine, but I do not know how to access Prober.

You can

access Prober by entering the URL in the browser:
http://
host
name
/mediaware/util/prober/index.htm
. For example, if the host name of
the web server is
http://202.42.200.221
, then enter the following URL
http://202.42.200.221/mediaware/util/prober/index.ht
m

in the
browser.



8

I can access Prober, but how do I access the database?

OpenAsia Solutions will provide you a special key file to be installed in the
mediaware/key/

directory (or the directory defined by
keyDir

in the configuration
file). You use the name

of the file (without the
.key
suffix) as the key to the database.

If you are using a ODBC database, you would need to set up a system DSN (data
source name) using the ODBC control panel.

If you are not using a ODBC database, you would need to install a J
DBC driver for
your database. You can get more information on various JDBC drivers at:
http://java.sun.com/products/jdbc/jdbc.drivers.html
. Refer to the
documentation of the JDBC drivers to set up the drivers.

Once the driver is set up properly, you can en
ter the key into the key field of the
Prober, enter a valid SQL statement into the SQL text field, and press the
Post to
Framer

button. It should return the resultset of the SQL statement.

Where is the configuration file and log file of MediaWare?

By defau
lt, they are in the
mediaware/

directory.




9

RMI
-
JDBC Installation

General

If you do not have a JDBC driver that can connect to the remote database (for
example, you are using the free JDBC
-
ODBC bridge and wanted to access the
remote Access database, or you

want to connect to a remote SQL Server from a
UNIX
-
based web server), you can use RMI
-
JDBC. RMI
-
JDBC will allow you to
access any remote database as if it is a local database. If you want to use RMI
-
JDBC,
this section describe a common scenario using set
ting up RMI
-
JDBC on a Windows
NT machine using the JDBC
-
ODBC bridge.

You can skip this chapter if you do not plan to use RMI
-
JDBC.

Setup of RMI
-
JDBC

Setup of the ODBC Data source

RMI
-
JDBC requires a JDBC driver to connect to a database. If you are using th
e
JDBC
-
ODBC Bridge, you would need to set up the ODBC datasource. In the following
example, we would be assuming you are using Windows machine running any ODBC
compliance database such as Microsoft Access or SQL Server. For setting up of
ODBC data source o
n other systems, please refer to the database manuals.

Try the example below on a machine dedicated as the web server. We are using the
web server as a database server for testing at this moment.

1.

create a database.

2.

click on start button and choose Settings
.

3.

Select Control Panel and double click on the ODBC (or 32bit ODBC) icon.

4.

Select the System DSN tab, the click on Add button.

5.

Select the database driver. For example, if you are using Microsoft Access, then
select the Microsoft Access driver.

6.

Click on Fin
ish button. A dialog box will appeared.

7.

Type a name in the Data Source Name input box. The will be the data source
name, or DSN, that we refers to in the future reference.

8.

Click on the Select... button to select the database file that you want to link to t
his
data source.

9.

You can also click on the Advanced... button to set up the user name and
password. This step is optional.

10.

You can now test your ODBC data source with Microsoft Query. Try a simple SQL
statement like select * from table name. If it does not

work, your ODBC data


10

source is not properly configured. Please try to solve this problem before going
further.

Test the JDBC/ODBC bridge

You should already have the Java Development Kit (version 1.1.6 or later) installed.

Type in the following Java progra
m and name it JdbcDemo.java. Please substitute the
DSN, user name and password in the listing with the values you set. In the case of not
having user name and password, let the two strings be empty.

//

// JDBC Demo

//


import java.sql.*;


public class Jdbc
Demo {


public static void main(String[] args) {


try {


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")


.newInstance();


String url = "jdbc:odbc:
dsn
";



java.sql.Connection c =


DriverManager.getConnection(url,


"
user name
", "
password
");


java.sql.Statement st = c.createStatement();


java.sql.ResultSet rs = st.executeQuery(


"select * from documents");



java.sql.ResultSetMetaData md = rs.getMetaData();



while (rs.next()) {


for(int i=1; i
<= md.getColumnCount(); i++)


System.out.print(rs.getString(i) + " | ");




System.out.println("");


}



rs.close();


} catch(Exception e) {


e.printStackTrace();


}


}

}


Compiled the program (javac JdbcDemo.java) and run i
t (java JdbcDemo). If
everything is fine, it should display some data on the screen.

Test the RMI
-
JDBC

Create a database on a remote machine dedicated as a database server, and follow
the above steps to create a data source for the database. You should als
o have RMI
-
JDBC installed and classpath set up in this machine

On the web server machine, type in the following Java program and name it
RmiJdbcDemo.java. Please substitute the host name of your machine, DSN, user


11

name and password in the listing with the
values you set. In the case of not having
user name and password, let the two strings be empty.

Note that this program is very similar to the program above. The differences are
highlighted in bold.

//

// RMI
-
JDBC Demo

//


import java.sql.*;

import java.rmi
.*;





import RmiJdbc.*;




import java.net.InetAddress;




public class RmiJdbcDemo {


public static void main(String[] args) {


try {


Class.forName("
RmiJdbc.RJDriver
").newInstance();


String url = "jdbc:odbc:
dsn
";

String rmiHost = "
host n
ame
";



java.sql.Connection c DriverManager.getConnection(


"jdbc:rmi:" + rmiHost + "/" + url, "
user name
",


"
password
");



java.sql.Statement st = c.createStatement();


java.sql.ResultSet rs = st.executeQuery(


"select

* from documents");



java.sql.ResultSetMetaData md = rs.getMetaData();



while (rs.next()) {


for(int i=1; i<= md.getColumnCount(); i++)


System.out.print(rs.getString(i) + " | ");




System.out.println("");


}



r
s.close();


} catch(Exception e) {


e.printStackTrace();


}


}

}


Compiled the program (javac RmiJdbcDemo.java).

On the database server machine, type the following command on the console:

java RmiJdbc.RJJdbcServer sun.jdbc.odbc.JdbcOdbcDriver

If successful, you should be seeing the following message:

Binding RmiJdbcServer...

sun.jdbc.odbc.JdbcOdbcDriver registered in DriverManager

/RmiJdbcServer bound in rmi registry




12

The command starts the RMI
-
JDBC server component.

Run the RmiJdbcDemo program

on the web server machine. If everything is properly
installed, some data will be displayed on the screen.

Administrating Database Server

At completion, RMI
-
JDBC is running. System Administrator needs to ensure that
rmijdbc

server component starts automat
ically on reboot.



13

MediaWare Servlets

Framer

Framer is used to parse a template and interprete the MediaWare related tags. It can
be used to pull data from the database and generate a dynamic document. It can also
be used to perform many other tasks.

It a
ccepts the following parameters:



template: a url for reading the template HTML file, which might contains tags for
components to access database. (optional)



errortmp: a url for the error template HTML file, which will be called when an error
in Framer occu
rred. (optional)



compress: whether the generated output is compressed or not. (true or false)



content: content type (text or html)

An example of calling Framer from an HTML file:

<form action="/servlet/Framer" method=POST>


<input type=hidden name=temp
late value="/template.html">


<input type=hidden name=errortmp value="/error.html">


<input type=submit>

</form>


If the template is omitted, Framer will construct a simple HTML page for you.

If the error template is omitted, the error message be s
tored in a variable called
error
.

The compression is default to off.

If the content type is
text
, the return result will be plain text, or else the default is
html
. This will affect how the browser render the returned output.

Execute Framer in command prom
pt

Framer can be executed from command prompt. To execute Framer, use the
following format:

java Framer
parameter1
=
value1

parameter2
=
value2

...



14

For example:

java Framer template="..." ...

This will call up Framer to parse the template. The result will be d
isplayed on screen.
Most operating systems allow you to redirect the output from screen to file.

You can either load the template from a web server (the complete address including
the host name has to be specified, for example:
http://www.OpenAsia
Solution
s.com/ /example.htm
) or loaded from the local harddisk (for example:
c:
\
templates
\
example.htm
).

You can load a configuration file from the local harddisk using the config parameter
(for example:
config = c:
\
mwconfig.txt
).



15

MediaWare Utilities

Router

The Ro
uter redirect a pseudo
-
form post to the web server.

To start Router, type on the command prompt:


java Router {configuration file name}

The default configuration file name is
rtconfig.txt

.

The configuration file has the following format:


action = full u
rl of servlet cgi program

(
eg,
http://202.42.200.151/servlet/Framer)



parameter key 1 = parameter value 1

(optional)


parameter key 2 = parameter value 2

(optional)


...


Timer

The timer tests the speed and robustness of CGI/servlet program. It will spa
wn off as
many threads as needed to attack the server and report the speed of the connections
and whether the connections break.

To start Timer, type on the command prompt:


java Timer {configuration file name}

The default configuration file name is
tmcon
fig.txt

.

The configuration file has the following format:



action = full url of servlet cgi program

(
eg,
http://202.42.200.151/servlet/Framer)


thread = number of threads


parameter key 1 = parameter value 1

(optional)


parameter key 2 = parameter value

2

(optional)


...


Mailer

Mailer allows the user to send an email.

To start Mailer, type on the command prompt:

java Mailer (configuration file name)



16

Security

Applet

CGI

Router

X.PRESSO

Gateway

Secure Server

Servlets or CGI
programs

The default configuration file name is
mlconfig.txt

.

The configuration file has the following format:



mailhost: name of mail host server


to: receipient name


from: sender name


subject message subject


message: message text


Secure Server

Using a security package X.PRESSO from Brokat, you can set up a secure 128
-
bit
connection with any servlets or CGI p
rograms.












Setting up Secure Server in X.PRESSO

After setting up X.PRESSO (refering to the X.PRESSO manual), add the following line
to the repository file:

addTCPIPDispatcherDestinationSettings SecureServer
\


/destinationHost=
h
ost name

\


/destinationPort=
9999

\


/useLengthAsHeader


The host name is the address of the Secure Server. The default port number is
9999
,
but you can change it to any port number >
8000
.

You would need to install the CGI Router from X.PRESSO (not to

be confused with
the MediaWare Router) into the cgi
-
bin directory of the web server.

Restart the X.PRESSO.

Database

X.PRESSO

Server

128 bit Encription

Client



17

Run the Secure Server

Create a file called
ssconfig.txt

that contains the following lines:


port = 9999


action = url of servlet cgi program

(eg,
ht
tp://202.42.200.151/servlet/Framer
)



parameter key 1 = parameter value 1
(optional)


parameter key 2 = parameter value 2

(optional)


...


If the cgi parameter cannot be omitted. If the port number is not specified,
9999

will be
used.


Start the Secure Se
rver by calling it from command prompt:


java SecureServer

Starting the Secure Applet

You will need to embed the Secure Applet in the HTML page for sending the data to
Secure Server.

To embed the Secure Applet:


<applet name=security code="SecureApplet.cla
ss"


width=1 height=1 MAYSCRIPT>



<param name=cgi value="
cgi
-
bin
/xpcgirtr.exe">



<param name=service value="SecureServer">



<param name=gateway value="
host name
">


</applet>


Replace the
cgi
-
bin

path by your cgi
-
bin server alias containing the C
GI Router.
Specified your host name of the X.PRESSO gateway.

You can send a series of parameters to the X.PRESSO server by calling the applet
with a string using the following format:


key 1 = value 1
\
n


key 2 = value 2
\
n


...


To call the applet, use t
he following JavaScript code:



reply = document.security.send(str);


The
str

is the parameter string. The applet will return a
reply

string which is the
result of executing the servlet or CGI program.



18


Template

Description

The template is a file with tag
s that is recognized by Framer or Mailer. The tag starts
with
<mw...>.

Some of the tags also have end tags that starts with
</mw...>.

This
chapter describes the tags you can use in the template.

The attributes of the tag can be written in many lines instea
d of one, like:


<mwlist



sql="select * from documents"



minHits=1



maxHits=1


>


If the attribute of the tag is omitted, it takes either its default value, or retrieve the value
passed on to it. For example, if the
sql

attribute in the
<mwfetch>

tag is

omitted, it
will retrieve the value from the
sql

variable that is set before executing the statement.


You can also embed a tag within a tag, such as:


<mwsetvar name=time value="<mwtime>">


You will need to put quotes (
"

or
'
) around the embedded tags.


You can use single quotes (
'
) within double quotes (
"
), and vice versa. You cannot
put single quotes within single quotes, and double quotes within double quotes.


The value of the attributes can be broken to many line of strings. For example:



<mwlist



sql = "select * from documents" +




"where title='love boat'" +




"order by title"


>


For the description of the MediaWare tags, refer to the
MediaWare Reference Guide
.



19


Extending MediaWare

General

You can extend the functionality of Framer by either w
riting a template or a Java
component called
Tag
. In either case, you create a
tags definition file

and
register it in
mwconfig.txt
.

The tags definition file is using the following format:

# Remark statement starts with a '#' sign

tag name

single/double

te
mplate URL/class name

The tag name is without the
mw

prefix. For example, the tag name for
<mwtest>

is
test
. Single means that it is a tag without a closing tag, and double means it is a tag
with closing tag.

Sample tags definition file:

# Sample tags



te
sttmp

single


/mywork/testtmp.htm


testjava

single


MyTag




Extending MediaWare with template

In the above example, after register the tags definition file in
mwconfig.txt
, you can
use
<mwtesttmp>

to include the template.

Extending MediaWare with Java com
ponent

Writing a Tag

Writing Tag is simple, here is an example:

//

// Hello

// Says hello!

//




import mw.Tag;

import limtc.Hash;


public class Hello extends Tag {


public String exec(Hash vars, StringBuffer out) {



// append to output stream




out.append("hello!");



20




// return no error



return "";


}

}


Put this line in your tags definition file:


hello


single


Hello

When a designer write a template file that contains this line:

My friend, <mwhello>

This is what will be returne
d when theFramer is called.

My friend, hello!

For a more complicated example, you will need to know the 2 arguments that is
passed to the Tag:
vars

and
out
.

The Tag contains all the attributes of the tag. For example, for
<mwhello
name=you>
,
getString("nam
e")

will return "
you
".

Hash vars

The Hash object
vars

is a set of variable that is passed to the Tag. Framer collects
the variables from the following place:

1.

Parameters that are passed to the Framer

2.

Variables that is being created in the template

StringBuf
fer out

The StringBuffer object
out

is for appending any message that is going to return by
Framer.

Writing a more complicated examples

For example, if you have a tag called
<mwlist>

that might embed some other
MediaWare tags, this is how a template might
look like:

<mwlist>

Here is the result: <mwcol name=product></mwcol>,
hopes you like it!




21

</mwlist>

The tokens will be an object array containing 3 objects:

1.

String: "
Here is the result
: "

2.

Tag: A Tag that can be executed
<mwcol></mwcol>

3.

String:
", hopes you

like it!"

It is up to the Tag to determine what do they want to do with the tokens object array.
They can either ignore it (like in the Hello example), or process it.

The Tag can access the Framer via an object
host
.

A simple processing routines will loo
k like this:


String str = host.execTemplate(tags, vars, out);


A more complicated processing routines will look like this:

// Loop through all the tokens



for (int i = 0; i < tags.size(); i++) {


Object obj = tags.getString(i);



// If it is
an instance of string, just append it.



if (obj instanceof String)


out.append(obj);




// It is a tag



else {





// Cast it to Tag object



Tag tag = (Tag) obj;




// Execute tag



String result = tag.exec(vars, out);



//
If tag returns error, handle it



if (result.length > 0)



return result;


}



return ""