Thursday, December 20, 2007

Java Util Logging in WebSphere Application Server

Use Java Util Logging in WebSphere Application Server


1. Create a Logger
Logger.getLogger("LoggerName");

Once this function is called, the logger is initialized.

2. logger name choosen

Generally, use package to generate the logger.
For large application, it is better to create in group or component.

such as com.package.COMMAND, com.package.USER, com.package.INVENTORY, com.package.ORDERS.
3. Level
For logging, use error or warning level.
For tracing, use fine, finner.

4. Handler
Do not need specify the handler explicitly. Leave WAS server to handle it.

5. Initialization
Here is the key point and the beauty of WAS.
At server startup, use Servlet initialization method to initialize all the loggers.
This will allow you to view all the logger components at WAS admin console.
Therefore, you have the full ability to control to turn on /off on specific tracing component.

6. Turn on/off tracing component
For the large application, you can always turn on/off tracing at run time without restarting the servers.
At WAS admin console, you can view the tracing components.
Use Runtime tab to turn it on/off for quick problem determination.

Monday, October 15, 2007

Configure Tomcat - Server.xml

<Context path="/testing" docBase="D:/temp/temp/mypath" reloadable="true"></Context>
<Context path="/test" docBase="E:/workspace/soft/myproject/WebContent" reloadable="true"></Context>

</Host>


</Engine>


</Service>


</Server>

Tuesday, August 14, 2007

Compose an email

Send an email:
Refer to infocenter : "Examples: Outbound messaging system interface".

To compose a jsp file, you need add to VIEWREG table.
Notice that, the deviceId is not -1, it should be the one used for email message. such as -3. Check database for detail.
Also, the interfacename and classname are different as regular viewreg.

Example to insert a new view:
-----------------------------
insert into viewreg (
VIEWNAME, DEVICEFMT_ID, STOREENT_ID, INTERFACENAME, CLASSNAME, PROPERTIES)values(
'OrderErrorNotificationView',-3, 0, 'com.ibm.commerce.messaging.viewcommands.MessagingViewCommand',
'com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl', 'docname=OrderErrorNotification.jsp&storeDir=no')

Saturday, May 12, 2007

Tuesday, April 10, 2007

Hashtable to iterator

Hashtable aTable = new Hashtable();
Set set = aTable.entrySet();
Iterator it = set.iterator();
while(it.hasNext()){
java.util.Map.Entry e = (java.util.Map.Entry) it.next();
String key = e.getKey();
String value = e.getValue();
}

Tuesday, March 13, 2007

BigDecimal error:

As API indicates, it is "immutable".
If you do following, it is wrong:

BigDecimal a = new BigDecimal("0");
BigDecimal b = new BigDecimal("1");
a.add(b); // wrong

a will not be changed.

Notice that add() method return BigDecimal object, which value is "this+val",
then this should be:
a = a.add(b);

Wednesday, February 21, 2007

What are inside "Message mappers" in WCS 561?

Snapshot of runtime object contents:

CommandContext
|_ adapter
|_ commandProperties - CommandProperty // Contains all properties
|_ sessionContext - CredentialsSpecifiedProgramAdapterSessionContextImpl
|_ commanProperty - CommandProperty // same as above commandProperties


commandProperties and commandProperty are pointing to same object, which contains:
-commandName
-executionProperties (Contains properties where their attributes are specified as 'FieldInfo=CONTROL'
in template file)
-requestProperties (same as getRequestProperties())


From infocenter, it says:
"Control
The name-value pair will be put into a "messageProperty" which contains control information
for the command, such as USERID or PASSWORD
"
I guess, here should be executionProperties instead of messageProperty

=================================================================
Quote from infocenter:
FieldInfo
Indicate the TypedProperty into which the name value pair should be placed. Data is the default.
If you want to put the name value pair into more than one TypedProperty, you must specify more
than one of the values listed below, separated by a comma:

Data
The name-value pair will be put into the a commandProperty object which contains arguments
for the command.
Control
The name-value pair will be put into a messageProperty which contains control information
for the command, such as USERID or PASSWORD
Command
The name-value pair is used to determine which command should be called. The generated
name-value pairs are used in the CommandMapping element of the TemplateDocument element.

Friday, February 16, 2007

XML over HTTP at WCS

XML over HTTP at WCS

WebSphere Commerce can receive inbound XML messages over HTTP.
From info center, it says:
---
The following steps illustrate the overall flow of an XML over HTTP request:

1. An external system sends an XML message to WebSphere Commerce over HTTP for example, http://host_name/webapp/wcs/stores/servlet/.
2. The request is mapped to the Program Adapter.
3. The Program Adapter passes the XML request to the appropriate message mapper.
4. The message mapper converts the XML request into a CommandProperty object and passes it back to the Program Adapter.
5. The Program Adapter prepares the command for execution and passes it to the WebController for execution.
6. The Program Adapter generates the proper XML response and returns the XML response to the external system that made the request.
---

So, how to create the request?

1. Use Java stand alone class to use socket function.
Here is my focus,if you want to send request through SSL channel, then you can initialize the socket with port 8000.
You have to establish the connection by creating the socket with port 80 first,
then, specify the port name following the HOST at header:

Example for header:

POST /webapp/wcs/tools/servlet HTTP/1.1
Host: hostname:8000
Content-Type: text/xml
Content-Length: 507

<?xml version="1.0" encoding="UTF-8"?>CONTENT...




2. Ajax solution
Seems fancy, but ...
Because Ajax does not support cross domain request,
it loses the point to use it. Why do we need a internal request (XMLHttpRequest)?

However, it seems the performance is better than socket.

Monday, February 12, 2007

The project was not built due to "Problems encountered while deleting resources."

Delete all the .class files of the project and refresh, to do a clean build .

Monday, January 29, 2007

JSTL date format

if I have a time in String format, and would like to output by using JSTL;
then this is what to do:

First, parse String to Date type:

<fmt:parseDate value="${someDateString}" pattern="yyyy-MM-dd HH:mm:SS" var="expireDate"></fmt:parseDate>

Second, output it with fmt:formatDate:
<fmt:formatDate value="${expireDate}" pattern="yyyy-MM-dd" />

The specified formatting pattern must use the pattern syntax specified by java.text.SimpleDateFormat.

Examples



The following examples show how date and time patterns are interpreted in
the U.S. locale. The given date and time are 2001-07-04 12:08:56 local time
in the U.S. Pacific Time time zone.












Date and Time Pattern
Result
"yyyy.MM.dd G 'at' HH:mm:ss z"

2001.07.04 AD at 12:08:56 PDT
"EEE, MMM d, ''yy"
Wed, Jul 4, '01
"h:mm a"
12:08 PM

"hh 'o''clock' a, zzzz"
12 o'clock PM, Pacific Daylight Time
"K:mm a, z"
0:08 PM, PDT
"yyyyy.MMMMM.dd GGG hh:mm aaa"
02001.July.04 AD 12:08 PM
"EEE, d MMM yyyy HH:mm:ss Z"
Wed, 4 Jul 2001 12:08:56 -0700
"yyMMddHHmmssZ"

010704120856-0700