Thursday, March 09, 2006

Some code to illustrate the unicode support by Character class

public class UnicodeTest{
public static void main(String... args) throws IOException
{
System.out.println("is valid codepoint : " + Character.isValidCodePoint(0x10FFFF));
System.out.println("is valid codepoint : " + Character.isValidCodePoint(0x20FFFF));
int cp = 0x10177;
System.out.println("is valid codepoint : " + Character.isValidCodePoint(cp));
char[] ch = new char[2];
ch = Character.toChars(cp);
int low = ch[0];
int high = ch[1];
System.out.println("Low Surrogate Pair : " + low + " Hexadecimal : " + Integer.toHexString(low) + " Binary String : " + Integer.toBinaryString(low));
System.out.println("High Surrogate Pair : " + high + " Hexadecimal : " + Integer.toHexString(high) + " Binary String : " + Integer.toBinaryString(high));
String st = new String(ch);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("krishna.xml"), "UTF-8"));
out.write("");
out.write("");
out.write(st);
out.write("
");
out.close();

}
}

In the above case, the supplementary character written in xml was not the one it is intended to be. Don't know whether it is the limitation of browser to display the supplementary characters or anything wrong in the way a supplementary character be handled in java code.

Some more understandings on java unicode support

From the start, java had used UTF-16 encoding for encoding the characters. Thus, in the earlier stages when the unicode character set was limited to 16 bits and hence was given full support by java character which was using the utf-16 encoding. Once the unicode was extended to support till the range U+10FFFF, the earlier UTF-16 encoded characters cannot represent characters more than U+FFFF. Hence, in J2se5, support was provided through the Character class. So, the primitive char still supports only the characters till code point: UTF+FFFF. The Java 2 platform uses the UTF-16 representation in char arrays and in the String and StringBuffer classes. In this representation, supplementary characters are represented as a pair of char values, the first from the high-surrogates range, (\uD800-\uDBFF), the second from the low-surrogates range (\uDC00-\uDFFF).

A char value, therefore, represents Basic Multilingual Plane (BMP) code points, including the surrogate code points, or code units of the UTF-16 encoding. An int value represents all Unicode code points, including supplementary code points. The lower (least significant) 21 bits of int are used to represent Unicode code points and the upper (most significant) 11 bits must be zero. Unless otherwise specified, the behavior with respect to supplementary characters and surrogate char values is as follows:

* The methods that only accept a char value cannot support supplementary characters. They treat char values from the surrogate ranges as undefined characters. For example, Character.isLetter('\uD840') returns false, even though this specific value if followed by any low-surrogate value in a string would represent a letter.
* The methods that accept an int value support all Unicode characters, including supplementary characters. For example, Character.isLetter(0x2F81A) returns true because the code point value represents a letter (a CJK ideograph).

Back to Unicode support in java

Again got confused in unicode. Some of the terms used are:
1. Coded Character Set
A character Set(collection of characters) where each character has been assigned a unique number. E.g., Unicode character set, where every character is assigned a hexadecimal number.
2. Code Points
The numbers that can be used in a coded character set. Valid code points for Unicode character set is : U+0000 to U+10FFFF (Unicode :4 standard)
3. Supplementary Characters
Characters that could not be represented in the original 16-bit design of Unicode. U+0000 to U+FFFF are referred to as Base Multilingual Plane(BMP) and the others are supplementary characters.
4. Character Encoding Scheme
Mapping from the numbers of one or more coded character sets to sequences of one or more fixed-width code units. e.g., UTF-32, UTF-16, and UTF-8
4. Character Encoding
Mapping from a set of characters to sequences of code units. e.g., UTF-8, ISO-8859-1, GB18030, Shift_JIS.

UTF-16
UTF-16 uses sequences of one or two unsigned 16-bit code units to encode Unicode code points. Values U+0000 to U+FFFF are encoded in one 16-bit unit with the same value. Supplementary characters are encoded in two code units, the first from the high-surrogates range (U+D800 to U+DBFF), the second from the low-surrogates range (U+DC00 to U+DFFF). This may seem similar in concept to multi-byte encodings, but there is an important difference: The values U+D800 to U+DFFF are reserved for use in UTF-16; no characters are assigned to them as code points. This means, software can tell for each individual code unit in a string whether it represents a one-unit character or whether it is the first or second unit of a two-unit character. This is a significant improvement over some traditional multi-byte character encodings, where the byte value 0x41 could mean the letter "A" or be the second byte of a two-byte character.


Monday, March 06, 2006

Least Integer to lose precision when converted to Floating point

The first integer at which assigning to float and casting back to int loses precision is : 16777217. The following code when run, gives the output as:

class Q44
{
public static void main(String[] args)
{
int i=0, y;
float j=0;
while(true)
{
j = i;
y=(int)j;
if( (y-i) != 0)
{
System.out.println("i = " + i);
break;
}
i++;
}
i = -1;
while(true)
{
j = i;
y=(int)j;
if( (y-i) != 0)
{
System.out.println("i = " + i);
break;
}
i--;
}


}
}


i = 16777217
i = -16777217

Floating points are first converted to form : N = ± (1.b1b2b3b4 ...)2 x 2+E
The left most one is not stored(always 1). The bits b1b2b3 etc.,(upto 23 bits) is what goes into the mantissa part. Hence, the first maximum bit for an integer can be 24 successive one's. (23 One's for mantissa and one implicit 1). 24 successive one corresponds to the number : 16777215. The next number is 16777216 for which the bit pattern is : 1000000000000000000000000
ie., one followed by 24 zero. So, even though the 24th zero is not stored, precision is not lost. Because when we convert back it is restored. So, the maximum integer without losing precision that can be converted back from float is now : 16777216

Now, if we consider the next number (16777217) for which the bit pattern is : 1000000000000000000000001. This has 1 followed by 23 zeros and then a 1. Because of 1 in the 24th bit, the 23rd bit will be rounded to 1 and the first precision loss comes for this number. Thus, the number 16777217 is the first integer number which when converted to float and converted back to integer will lose the precision as proved by the output of the above code.

Wednesday, March 01, 2006

.Net Framework

Was feeling lazy to work today. Hence, looked at .net framework programming......Some highlights of points learnt for future reference
1. .Net currently supports around 20 languages to be compiled into IL(Intermediate Language) format.
2. For shift from J2EE to dot net, c# can be a better option.
3. A simple helloworld C# code is:
class App{
public static void Main(){
System.Console.WriteLine("Hello World!");
}
}
4. To compile the above code, type "csc filename.cs". This generates the filename.exe. (for vb, use vbc and for javascript, jsc)
5. Hierarchy : Managed Executable -> CLR(JIT compilation) -> OS
6. CLR is similar to the other execution engine like JVM for J2EE. The CLR supplies memory management, type safety, code verifiability, thread management and security.
7. Important points are
  • Managed Code is never interpreted

  • Managed code doesn't run in virtual machine.

8. CIL(Common IL) is the high level assembly language includes instructions for advanced programming concepts as instantiating objects or calling virtual functions.
9. The CLR translates these and every other IL instruction into a native machine language instruction at runtime, and then executes the code natively.
10. Metadata describes class definitions, method signatures, parameter types and return values.
11. The exe generated out of compiling the managed code contains the metadata and the IL. We can use the IL disassemebler(ILDASM) to view the structure of the managed exe.
12. At runtime, this exe is JIT compiled by the CLR and converted into the machine language instructions.
13. Some of the benchmarck results shows dot net executed code is 2-3 times faster than the J2EE...

JIT COMPILATION
The first time that a managed executable references a class or type (such as a structure, interface, enumerated type or primitive type) the system must load the code module or managed module that implements the type. At the point of loading, the JIT compiler creates method stubs in native machine language for every member method in the newly loaded class. These stubs include nothing but a jump into a special function in the JIT compiler.

Once the stub functions are created, the system fixes up any method calls in the referencing code to point to the new stub functions. At this time no JIT compilation of the type's code has occurred. However, if a managed application references a managed type, it is likely to call methods on this type (in fact it is almost inevitable).

When one of the stub functions is called the stub causes execution to jump into the JIT compiler. The JIT compiler looks up the source code (IL and metadata) in the associated managed module, and builds native machine code for the function on the fly. Then, it replaces the stub function with a jump to the newly JIT compiled function. The next time this same method is called in source code, it will be executed full speed without any need for compilation or extra steps.

The good thing about this approach is that the system never wastes time JIT compiling methods that won't be called by this run of your application.

Friday, February 03, 2006

ADF active data model

This link explains how a change to model is automatically notified to client in case of ADFBC, so that there is no need to transfer the data back and forth.

Friday, December 16, 2005

Java Unicode Support

Check the JSR-204 for java unicode support : JSR-204

Supplementary Character Support Approach
  • Use the primitive type int to represent code points in low-level APIs, such as the static methods of the Character class.

  • Interpret char sequences in all forms (char[], implementations of java.lang.CharSequence, implementations of java.text.CharacterIterator) as UTF-16 sequences, and promote their use in higher-level APIs.

  • Provide APIs to easily convert between various char and code point based representations.


Good blog on unicode support in j2se5 : John Conner blog
Highlights:
# char is a UTF-16 code unit, not a code point
# new low-level APIs use an int to represent a Unicode code point
# high level APIs have been updated to understand surrogate pairs
# a preference towards char sequence APIs instead of char based methods

Java Floating point

Good link for java floating point : http://people.uncw.edu/tompkinsj/133/Numbers/Reals.htm

IEEE 754:
The IEEE 754 Standard uses 1-plus form of the binary normalized fraction (rounded). The fraction part is called the mantissa.
1-plus normalized scientific notation base two is then

N = ± (1.b1b2b3b4 ...)2 x 2+E

The 1 is understood to be there and is not recorded.
The Java primitive data type float is 4 bytes, or 32 bits:

Sign: 0 ® positive, 1 ® negative.

Exponent: excess-127 format for float, excess-1023 format for double.

* Float: Emin = -126, Emax = 127
* Double: Emin = -1022, Emax = 1023
* Consider an 8 bit number which has a range of 0 - 256. We use the formula excess - 127 = E to assign the value of our exponent with excess = 127 representing 0.
* In this manner, excess = 120 is an exponent of -7 since 120 - 127 = -7, and excess = 155 is the exponent +28 since 155 - 127 = +28. Excess values of 0, (Emin - 1), and 255, (Emax + 1), have special meanings which are discussed below.

Mantissa: normalized 1-plus fraction with the 1 to the left of the radix point not recorded, float: b1b2b3b4…b23, double: b1b2b3b4…b52. This value is rounded based on the value of the next least significant bit not recorded (if there is a 1 in b24, b53 respectively, increment the least significant bit).

Thursday, December 15, 2005

Static Method Inheritance

This link : http://java.sun.com/docs/books/tutorial/java/javaOO/override.html explains this issue with details.

For class methods, the runtime system invokes the method defined in the compile-time type of the reference on which the method is called. For instance methods, the runtime system invokes the method defined in the runtime type of the reference on which the method is called.

I paste here the same for easy reference:

public class Animal {
public static void hide() {
System.out.println("The hide method in Animal.");
}
public void override() {
System.out.println("The override method in Animal.");
}
}

The second class, a subclass of Animal, is called Cat:

public class Cat extends Animal {
public static void hide() {
System.out.println("The hide method in Cat.");
}
public void override() {
System.out.println("The override method in Cat.");
}

public static void main(String[] args) {
Cat myCat = new Cat();
Animal myAnimal = (Animal)myCat;
myAnimal.hide();
myAnimal.override();
}
}

The Cat class overrides the instance method in Animal called override and hides the class method in Animal called hide. The main method in this class creates an instance of Cat, casts it to a Animal reference, and then calls both the hide and the override methods on the instance. The output from this program is as follows:

The hide method in Animal.
The override method in Cat.

The version of the hidden method that gets invoked is the one in the superclass, and the version of the overridden method that gets invoked is the one in the subclass. For class methods, the runtime system invokes the method defined in the compile-time type of the reference on which the method is called. In the example, the compile-time type of myAnimal is Animal. Thus, the runtime system invokes the hide method defined in Animal. For instance methods, the runtime system invokes the method defined in the runtime type of the reference on which the method is called. In the example, the runtime type of myAnimal is Cat. Thus, the runtime system invokes the override method defined in Cat.

An instance method cannot override a static method, and a static method cannot hide an instance method.

Saturday, November 19, 2005

Multi-Boot Linux with Windows XP

Installed Fedora and Ubuntu with windows XP. Steps to be taken:
1. Boot from linux CD in CD-Rom
2. During partition, select 'Advanced' checkbox in case of Fedora. In case of Ubuntu use the Guided partitioning option.
3. These install GRUB loaded by default in MBR. But, better option I feel(and did) is to install the GRUB loader in the boot partition of the linux itself and take a copy of the boot part using tool like bootpart and add it to the boot.ini of the windows.

Issues in installing Ubuntu:
- Installation of ubuntu is in two parts. First base image is installed and then additional packages are installed. After the base images were installed, it made the linux partition as "Active" partition. Thus, it is always going to be the GRUB loader which will load the OS. In order to change it back to the windows loader, need to make the windows partition as "Active". One issue I encountered was that after making the windows partition as active and rebooting the system, the other windows partition became hidden. Setting this partition to "UnHide" using partition manager also didn't solve the problem of unhiding this partition. To solve this problem, the GNU "parted" tool of linux came to my help. Using this, I set the windows partition to unhide. Then did a reboot. Now my windows partition became unhidden. GNU parted helped me to solve this issue which even partition magic cannot fix.

Thursday, October 13, 2005

ADF : Class Casting Exception with ApplicationModule

1. I have written my Base applicationmodule(say, CatalogApplicationModuleImpl) extending ApplicationModuleImpl in my frameworkextension Project.
2. Then in the Model project which is dependent on this fwkextension project, I write my ApplicationModule(say, CatalogServiceImpl) extending CatalogApplicationModuleImpl.
3. Then I expose some of the methods of CatalogServiceImpl through a interface CatalogService to the DataAction classes in controller.
4. Now similar to AM, I've base controller CatalogDataForwardAction in fwkextension project which is extended by the actual dataaction classesin the viewController project. In the base controller i've the utility method:

protected CatalogApplicationModuleImpl getApplicationModule(String dataControlName,DataActionContext ctx)
{DCDataControl dc = ctx.getBindingContext().findDataControl(dataControlName);
if ((dc != null) && dc instanceof DCJboDataControl)
{return (CatalogApplicationModuleImpl) dc.getDataProvider();}
return null;}

5. This is the same method as in Toystore project of SMUENCH. The changeis I'm casting the CatalogServiceImpl(from dc.getDataProvider()) to itsbase class CatalogApplicationModuleImpl, so that I can invoke some methodson the base AM(CatalogApplicationModuleImpl) from the base controller(CatalogDataForwardAction). I need this since I'm writing some methods inthe base controller which need not be replicated in all the controllers implementing this class.
6. The problem is that the above casting fails. I understand that by the above I'm trying to cast a class to a Impl class which is not present in the client side(controller) and hence this exception. If that is the case, what is the wayI can access the methods in the base AM(CatalogApplicationModuleImpl)from the base controller(CatalogDataForwardAction)(these two classesare present in the fwkExtension project). i.e., how can I expose theCatalogApplicationModuleImpl to the controller(should I have to writethis Impl as implementing some interface and use that interface in thebase controller. If so, where should the base interface be created?
Thanks,Krishna.

ADF:Setting of who columns(Audit columns) in the Entity Object

Posted the following question in jdeveloper forum today
I have who columns like created_by, creation_date, last_update_date, last_updated_by etc., in the table(and so the entity object). These need to get set based on the user logged in. Currently, I'm achieving the same by following logic:
1. Wrote my own TransactionImpl extending DBTransactionImpl2 and registeredthe transaction factory to the application module.
2. In my transactionImpl, there is a setter method: public void setUserId(int userId)
3. I've a filter to redirect the user to login page if not logged in. In the filter Istore the userid in the session, if user is authenticated.
4. Everytimein the DataAction PrepareModel phase, I invoke the methodsetUserId on the applicationModule passing the value from the session, whichsets the same in the TransactionImpl. Then in the EntityObject create method,I access this value to set the userId. I call the setter in all theaction class(so that if in the next request I get a different application moduleor a different transaction due to transaction/AM harvesting, the statevariable may be lost and hence in the preparemodel phase i explicity set them). Is this correct or any other way I can achieve the same
5. My next question is : how do I set these last_update_date and last_updated_by when the entity object is queried and changed. I can do thisin SetAttributeInternal Method(with a check that the index is not these twoattributes). However, this logic will then become tied to a particular entityobject. I want this logic to be written in my base class of EntityImpl so thatall EntityImpl extending my base EntityImpl will have this logic incorporatedautomatically.
Please let me know how can I acheive this.
Thanks,Krishna.

Saturday, September 17, 2005

Stock Market Learnings

Technical Analysis
1. Bar Chart
A single vertical line with opening price on the left side and the closing price on the right side. The advantage of using a bar chart over a straight line graph is that it shows the high, low, open and close for each particular day.
2. CandleStick Charting
A vertical line with a cylindrical body. Body is black or red if stock closed lower. Body is white or green if stock closed higher.
Patterns :
  • Bullish : cylindrical equispaced between low and high,

  • Bearish : cylindrical portion more at the bottom of the line.

  • Hammer : small cylindrical portion at the top of the line : indicate the reveral in downtrend is in the works

  • Star : a single horizontal line at the center of a vertical line - stock going to change its course


3. Point and Figure Chart
Mainly for intraday charting.
increases are represented by a rising stack of "X"s, while decreases are represented by a declining stack of "O"s.
4. Moving Average Chart
Average value of price over a period of time. 50 day average chart->average of 50 days closing price. The most commonly used moving averages are of 20, 30, 50, 100 and 200 days.Typically, when a stock price moves below its moving average it is a bad sign because the stock is moving on a negative trend. The opposite is true for stocks that exceed their moving average - in this case, hold on for the ride.
5. The Relative Strength Index
RSI = 100 - [100/(1 + RS)]
where:
RS = (Avg. of n-day up closes)/(Avg. of n-day down closes)
n= days (most analysts use 9 - 15 day RSI)
At around 70, stock is overbought. Better to sell at this point. In a bullish market, wait till 80
At around 30, stock is oversold. Better to buy at this point. In a bearish market, wait till 20
6. The Money Flow Index
Average price for the day:

Average Price = (Day High + Day Low + Close ) / 3
Now we need the Money Flow:
Money Flow = Average Price x Day's Volume
If the price was up in a particular day, this is considered to be "positive money flow". If the price closed down, it is considered to be "negative money flow".
Money Flow Ratio = (Positive Money Flow ) / (Negative Money Flow)
Other Methods

  • Support and Resistance

  • Bollinger Bands

Friday, September 02, 2005

Struts html checkbox : unchecked is not getting posted

Recently posted a question in oracle jdeveloper forum :
If a struts html checkbox is unchecked, then when submitting this form containing this checkbox, the checkbox value is not getting posted. Hence, the same is not getting reflected in themodel. So, to post the unchecked value also, what should I do?
Got the reply:
Read the Struts newbie FAQ : http://struts.apache.org/faqs/newbie.html#checkbox

Thursday, August 25, 2005

The UTF-8 encoding rules

1. Characters U+0000 to U+007F (ASCII) are encoded simply as bytes 0x00 to 0x7F (ASCII compatibility). This means that files and strings which contain only 7-bit ASCII characters have the same encoding under both ASCII and UTF-8. A single byte is needed for any of these characters!
2. All characters >U+007F are encoded as a sequence of several bytes, each of which has the most significant bit set. Therefore, no ASCII byte (0x00-0x7F) can appear as part of any other character.
3. The first byte of a multibyte sequence that represents a non-ASCII character is always in the range 0xC0 to 0xFD and it indicates how many bytes follow for this character. All further bytes in a multibyte sequence are in the range 0x80 to 0xBF. This allows easy resynchronization andmakes the encoding stateless and robust against missing bytes
4. All possible 231 UCS codes can be encoded
5. UTF-8 encoded characters may theoretically be up to six bytes long, however 16-bit characters (the ones implicitly supported in the UCS-2 encoding, and by Str Library) are only up to three bytes long
6. The sorting order of Bigendian UCS-4 byte strings is preserved
7. The bytes 0xFE and 0xFF are never used in this encoding

The following byte sequences are used to represent a character:

U-00000000 - U-0000007F: 0xxxxxxx
U-00000080 - U-000007FF: 110xxxxx 10xxxxxx
U-00000800 - U-0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx
U-00010000 - U-001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
U-00200000 - U-03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
U-04000000 - U-7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx

The xxx bit positions are filled with the bits of the character code number in binary representation. The rightmost x bit is the least-significant bit. Only the shortest possible multibyte sequence which can represent the code number of the character can be used. Note that in multibyte sequences, the number of leading 1 bits in the first byte is identical to the number of bytes in the entire sequence.

Wednesday, August 24, 2005

Form Submission

Form content types
The enctype attribute of the FORM element specifies the content type used to encode the form data set for submission to the server. User agents must support the content types listed below. Behavior for other content types is unspecified.
Please also consult the section on
escaping ampersands in URI attribute values.
application/x-www-form-urlencoded
This is the default content type. Forms submitted with this content type must be encoded as follows:
Control names and values are escaped. Space characters are replaced by
`+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').
The control names/values are listed in the order they appear in the document. The name is separated from the value by
`=' and name/value pairs are separated from each other by `&'.
multipart/form-data
Note. Please consult
[RFC2388] for additional information about file uploads, including backwards compatibility issues, the relationship between "multipart/form-data" and other content types, performance issues, etc.
Please consult the appendix for information about
security issues for forms.
The content type "application/x-www-form-urlencoded" is inefficient for sending large quantities of binary data or text containing non-ASCII characters. The content type "multipart/form-data" should be used for submitting forms that contain files, non-ASCII data, and binary data.
The content "multipart/form-data" follows the rules of all multipart MIME data streams as outlined in
[RFC2045]. The definition of "multipart/form-data" is available at the [IANA] registry.
A "multipart/form-data" message contains a series of parts, each representing a
successful control. The parts are sent to the processing agent in the same order the corresponding controls appear in the document stream. Part boundaries should not occur in any of the data; how this is done lies outside the scope of this specification.
As with all multipart MIME types, each part has an optional "Content-Type" header that defaults to "text/plain". User agents should supply the "Content-Type" header, accompanied by a "charset" parameter.
Each part is expected to contain:
a "Content-Disposition" header whose value is "form-data".
a name attribute specifying the
control name of the corresponding control. Control names originally encoded in non-ASCII character sets may be encoded using the method outlined in [RFC2045].
Thus, for example, for a control named "mycontrol", the corresponding part would be specified:

Content-Disposition: form-data; name="mycontrol"
As with all MIME transmissions, "CR LF" (i.e., `%0D%0A') is used to separate lines of data.
Each part may be encoded and the "Content-Transfer-Encoding" header supplied if the value of that part does not conform to the default (7BIT) encoding (see
[RFC2045], section 6)
If the contents of a file are submitted with a form, the file input should be identified by the appropriate
content type (e.g., "application/octet-stream"). If multiple files are to be returned as the result of a single form entry, they should be returned as "multipart/mixed" embedded within the "multipart/form-data".
The user agent should attempt to supply a file name for each submitted file. The file name may be specified with the "filename" parameter of the 'Content-Disposition: form-data' header, or, in the case of multiple files, in a 'Content-Disposition: file' header of the subpart. If the file name of the client's operating system is not in US-ASCII, the file name might be approximated or encoded using the method of
[RFC2045]. This is convenient for those cases where, for example, the uploaded files might contain references to each other (e.g., a TeX file and its ".sty" auxiliary style description).
The following example illustrates "multipart/form-data" encoding. Suppose we have the following form:

enctype="multipart/form-data"
method="post">


What is your name?

What files are you sending?



If the user enters "Larry" in the text input, and selects the text file "file1.txt", the user agent might send back the following data:
Content-Type: multipart/form-data; boundary=AaB03x

--AaB03x
Content-Disposition: form-data; name="submit-name"

Larry
--AaB03x
Content-Disposition: form-data; name="files"; filename="file1.txt"
Content-Type: text/plain

... contents of file1.txt ...
--AaB03x--

If the user selected a second (image) file "file2.gif", the user agent might construct the parts as follows:
Content-Type: multipart/form-data; boundary=AaB03x

--AaB03x
Content-Disposition: form-data; name="submit-name"

Larry
--AaB03x
Content-Disposition: form-data; name="files"
Content-Type: multipart/mixed; boundary=BbC04y

--BbC04y
Content-Disposition: file; filename="file1.txt"
Content-Type: text/plain

... contents of file1.txt ...
--BbC04y
Content-Disposition: file; filename="file2.gif"
Content-Type: image/gif
Content-Transfer-Encoding: binary

...contents of file2.gif...
--BbC04y--
--AaB03x--

Friday, July 22, 2005

ADF Event handling precedence

When an event named YourEvent fires, then...

If you have apublic void onYourEvent(DataActionContext ctx) method in the data action class handling the request, it will be invoked to handle the event with custom code.
If you have an action binding in the current binding container named YourEvent, it will be invoked.

When used in combination with 1, your event-handler code needs to explicitly invoke the default action for the current event by using code like:

if (ctx.getEventActionBinding() != null) ctx.getEventActionBinding().doIt();
If you have a Struts forward named YourEvent, it will be used to determine the next page to forward control to.

When used in combination with 1, if your event-handling code invokes ctx.setActionForward(), then your programmatically set forward takes precedence.

Thursday, July 21, 2005

ADF : Creating PreparedStatements

While creating preparedStatement from Application Module, it is better to not close them in a finally block. But, close them in the overridden remove() method of the AM by calling some method which will close all the local statements. Thus, will improve performance.

Saturday, July 02, 2005

Vector or ArrayList

Checked this site : Vector or ArrayList. Vectors are synchronized, while ArrayList is unsynchronized(making them not thread-safe). A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent(when full)...

Thursday, June 23, 2005

Raaga Player not working after RealPlayer 10.5 Upgrade

After upgrading to real player 10, cannot play songs from raaga.com. This was due to the firewall issue. Did the following things to make it work again.
1. Uninstalled the real player 10 and installed the real player 8
2. Set the RNSP setting and PNA setting in the Transport tab of preferences to "Use HTTP only".
3. Now it works.(The step.2 done in real player 10 still doesn't allow to play songs..don't know yy)

Note: For my laptop, even realplayer 8 had some problem. So, installed realoneplayer version 2(realplayer20) and did the above settings. It worked.