Sunday, July 19, 2009

Cookies - 1st Party & 3rd Party

Its been long time since i blogged last. Recently have been working on Analytics for websites. So thought of writing about a key enabler for collecting visitor data from the information or knowledge i gained
Many of us would have seen or heard about cookies. Every website you visit will download a cookie to your hard disk. But there are different types of cookies and their need which i would try explaining below.

First, What are cookies? There are many definitions like
-- A small data file placed on your computer by a website that you visit.
-- A piece of code placed in your browser by a website server.
-- A text file placed on a hard drive to store and transmit information to the server browsing behaviour of customer.

Reports and research on the subject of website tracking tell us that the rejection of third-party cookies is growing. Increasing numbers of people are either manually blocking third-party cookies, or deleting them reguarly.

How many people delete 3rd party cookies? The numbers given can be as high as 40%. If you count that many anti-spyware applications and default privacy settings also block 3rd party cookies, then it is possible that a high percentage of cookies are being blocked.

What is a (third-party) cookie?
A cookie is a small script placed on the hard drive of your computer by the server of a website that you visit. The cookie is placed there for the purpose of recognising your specific browser / computer combination, were you to return to the same site.

All cookies have an owner which tells you who the cookie belongs to. The owner is the domain specified in the cookie. The word "party" refers to the domain as specified in cookie; the website that is placing the cookie. So, for example, if you visit http://www.site1.com/ and the domain of the cookie placed on your computer is http://www.site1.com/, then this is a first-party cookie. If, however, you visit http://www.site1.com/ and the cookie placed on your computer says http://www.site2.com/, then this is a third-party cookie.

Then the question - Would these first party cookies not deleted or blocked? will arise.
It is estimated that a very low percentage of people block first party cookies, less than 5%. The reason for this is primarily that it is very difficult to surf the internet without accepting these cookies. First party cookies are necessary in order for you to be recognised as an individual. Any site that you login to as an individual requires a way of identifying you as "you". Hotmail, Yahoo, Gmail, online banking, ebay, Amazon, etc.

Also software targetted for Cleaning the hard disk for unused, temporary files, anti spyware etc., do not target first-party cookies.

We use cookies to keep track of long-term visitors. These visitors remain anonymous, the point is to be able to see who returns, if and when, for example, for conversion analysis.

When cookies are in place, and not blocked or deleted, total visitor counts will remain comparatively low. If a person constantly deletes cookies, they will be counted as a new "unique" visitor with every subsequent visit.

In response to these trends, the first step is to find out if the statistics that you collect utilise first-party or third-party cookies. Ask your statistics or tracking company. Asking questions usually leads to more questions, always a good thing when it comes to gathering and analysing data.

Thursday, December 4, 2008

Error While invoking webservices in WASv5.1.*

This post may not be of much importance as this talks about a possible error while invoking webservices by the applications running in WAS version 5. (This is already obsolete, and most of the apps are now migrated to higher versions). Just in case, if anyone faces this error, will be useful (No information is available in Web).

When a webservice is invoked from the application running in WASv5.1.1.5, if the below error is being seen.

org.omg.CORBA.portable.UnknownException: vmcid: 0x0 minor code: 0 completed: Maybe

at com.ibm.ejs.csi.OrbUtilsImpl.mapException(OrbUtilsImpl.java:88)
caused by
java.lang.NoSuchMethodError: com.ibm.ws.webservices.engine.description.ParameterDesc: method (Ljavax/xml/namespace/QName;BLjavax/xml/namespace/QName;Ljava/lang/Class;ZZZZ)V not found

This is because of the version of the jar files used - webservices.jar and wsdl4j.jar. Check the versions being used in the app server lib folder. And replace with the right versions containing the above definition of method.

ParameterDesc is a class inside webservices.jar and has a constructor with 8 arguements, which is not found in the above case.
Also, the QName is referred to javax.xml.namespace package instead of appropriate package as defined in wsdl4j.jar. As it is not able to resolve the right package, defaults to javax package for QName.

Hope this helps.

Tuesday, October 28, 2008

Heap n Stack

To explain the answer to my earlier post - "Simple One But...", first the difference between two memory areas in Java - heap and stack has to be understood.

Whenever a program runs in JVM, different ways the memory is managed is depicted in the figure below.

Now coming back to the earlier question, so whenever a methos is executed, it creates a new data record on Stack. So each instance of method call has a exclusive data record associated with it. (Figure 2) . And when a method calls other methods, records of the called methods are stacked up along with the caller. (Figure 3).

This explains or answers for the below, as static methods would be no different from non-static methods, but there is a catch here. This statement is correct only if the arguments are primitives, but when they are objects, the objects would still reside on Heap and are referred from within the stack. (Figure 4)
So finally remembering where a particular element lives, heap or stack:: a local variable (primitive or reference) belongs to a method and lives with it on a stack, while instance variable belongs to an object lives with it on a heap. Also note that a local reference variable on a stack will still be pointing to object in the heap. This object will not die with the local reference variable or post method execution.

Note: figures displayed are extracted from book (in Google Book Search) - SCJP Exam for J2SE 5 by Paul Sanghera and from lecture slides of Gerald Weber.

Tuesday, October 21, 2008

Chordiant 6.2 - QueueItem Attribute or Properties - To hold a value in runtime

Before we go ahead, QueueItem is used in case of dynamic processflows, where the requirement is to push into and pull out from queues. Typical example would be any authorisation workflow having hierarchies.

In such scenarios of implementing chordiant workflows, all the service flow information is stored in DB. (jxwwflow and jxwtask tables). State of the process and context variables data are stored inside blob column in jxwwflow table.

Now, if we need a queue item to display a value captured in runtime, the queueitem attribute or property should be set with the value available in runtime. Below are the steps..

1. Open the xml file - 'bpdconstraints.xml' available at ChordiantEAR/config folder.
2. Edit the xml by adding the properties or attributes required. Example -

3. Open Window-Preferences inside RAD and choose BPD in left menu. In the lower panel, select the above file in "Source for QRT queue, user, and property names".

The above proceedure is to define the attributes or properties to be mapped with runtime values. Now, In BPD Perspective, select the task required and in the Properties tab

4. Inside Task properties select Queue and Route properties and click the button present.
5. In the popup, under tab properties, you should be able to see the properties added in the above xml. Select the required and accordinly map it to a value, expression or variable (select workflow scope and context variable. )

Then value at runtime present in context variable is mapped to the property and then can be used. In case attribute is required, use attribute tab and do the same.

Simple One but ....

In the past 5+ years of my experience as a Jave Panelist for the recuritment drives in company, most regular question by me is this

What is static? What does it mean when a method is declared static - Ofcourse the most obvious answers would be - Static means only one instance per class. And when method is static, only one instance exists for that class. - Immediately my reaction would be a sharp smile as the candidate fell into trap.

My next question is - Then i have a method called add as below.

public static void add (int a, int b) {
int sum = 0;
sum = a + b;
System.out.println("Sum equals -- " + sum);
}

What is the result when two concurrent threads access the same method with inputs (3,4) and (4,5).

Will the execution gives right results or wrong results? if so why?
about 99% of cases have this wrong by first saying right results and when i point back to their definition of having a single instance and stressing on 2 concurrent threads, answer changes to defining the method syncronized. Then to further test his reasoning, i would say, so do you mean every method declared static should have syncronized as mandatory. Bowled!!!!!

Any tries are welcome..will exlain later...

Note: this is just to explain/test a simple java basic, not that i am saddist with the candidates. Having got bored asking typical questions as listed in many websites - java intervew questions etc., try asking un-orthodox questions.

Friday, October 17, 2008

"SCORN" - Keyword for analysing UI performance

Good article i have read on Analysing the Front End performance of any web application. The Key points are .....

SCORN stands for the following:
Size -- Caching -- Order -- Response codes -- Number
Below is the brief explanation of each of the above parameters.


Size: When it comes to website performance, smaller is better. Whether it's a graphic, a script or the base HTML page, it has to get from the server to client at least once, and that trip is bound to take less time when there is less information to transmit. Specifically look for uncompressed graphics and media, object or code duplication, script and styles living outside of the base HTML, and code "minification."


Caching: Any page or object that users will view more than once is worth at least considering caching on the client side. The trick is balancing the relative speed of pages and objects being displayed from cache with the fact that objects displayed from cache may not be the most recent version. Check for Expires settings, ETags and other client-side cache controls to see if they strike a sensible balance between object load time and object freshness.

Order: Possibly the most dramatic user-perceived performance gain can be achieved by requesting component objects in the correct sequence. In most cases, the sequence of objects should be as follows:
Styles/style sheets
Critical content (i.e. what the user came to the page to see)
Relevant media (i.e. graphics related to the critical content)
Incidental content (i.e. non-critical graphics, possibly advertisements)
Scripts


Response codes: Checking response codes for each object can help identify requests for objects that don't actually exist, superfluous redirects and errors that aren't apparent from the browser. Each of those can cost more time than getting the object without error/redirect or eliminating the unused request entirely.

Number: For the most part, fewer is better. But depending on a user's connection speed, several smaller graphics may be faster than one large one. In the vast majority of cases, one external style sheet and one external script file will be fastest. It's worth asking questions if the number of objects impresses you as other than "fewer".

For more details refer to --
http://searchsoftwarequality.techtarget.com/tip/0,289483,sid92_gci1301766,00.html?track=NL-516&ad=659546&asrc=EM_USC_4391444&uid=4931891

New feature - Scope of Page Bean is Process!!

In the last 2.5 years of experience working in Chordiant projects, i have seen many instances, when a very simple and most common requirement in a JSP when implemented in JSF, turned into nightmare. Whenever we need the same page to be presented to the customer more than once, based on his actions, example when you select a dropdown, screen refreshes to present different details etc., to contain all the values previously captured, either we need to have the page bean scope defined as session or if not have the bean in request scope and place the objects in IOMap or session and access them each time. This would be pretty complex to maintain and have performance impact as the load increases.

Recently, there is an enhancement in Interaction Controller layer of Chordiant 6.3 to handle this. The gist of the same is below.. (Derived from Chordiant Mesh.)

The main idea is to move the request scoped bean into the same scope as the client task and so rather than represent a page, these beans represent the client task itself. The second enhancement is to provide a set of annotations to simplify validation and “next” processing.

Process Scoped client task beans ----> Subclassing ICFacesBackingBean automatically places the bean in process scope which can then be accessed from the page. The subclass needs to defined in faces config as request scope just as before. Or provide the text in @Name annotation that matches what the ic framework is looking for.

The bean is placed in process scope under the name “pageBean”. The backing bean superclass looks after managing this bean in its scope and unlike the default chordiant jsf framework, it instantiates the bean before the page is rendered. This allows a certain amount of preprossing before the page renders which is useful.

You can then access the bean from your page by using #{processScope.pageBean}. As the bean is maintained in processscope for the duration of the client task, validation loops and ppr calls are much easier as temporary state can be stored directly on the bean.

This framework to make things simpler had made use of annotations. They are

@Name(value)This is a type level annotation and is optional. If you give the bean a name that matches the ic name for it, e.g. @Name("ic$idverify_selectCustomer"), then you don't need the faces-config entry

@PreProcess This is marked on a single method and is invoked after the bean is created. The bean is created on the back of a response from start or next. The client task object is available at this point and so bean initialization can occur. Most common uses for this is to take what is on the iomap and turn it into something more useful for the bean. This could be as simple as putting the customer object as an attribute of the bean.

@Pack(choice)This annotation takes an optional choice argument. Without an argument, it will get executed when next is run. If it is supplied with a choice, then it will only get executed for that particular choice. Note the general @Pack always get executed.

@Validate(choice)Similar to the @Pack annotation, this gets executed during the validation phase (chordiant, not JSF). The general, non-choice @Validate is executed and then any specific ones that match the choice. For example, if you had a back button on your page and which was bound to next but you didn’t want to validate on it, you might only annotate a validation method with @Validate(choice=”next”).

The following example shows a client task responsible for selecting a customer.
--------------------
@Name("ic$idverify_selectCustomer")
public class SelectCustomerBean extends ICBackingBaseBean {

private List customers; private CoreTable table;
public List getCustomers() { return customers; }
public void setCustomers(List customers) { this.customers = customers; }
public CoreTable getTable() { return table; }
public void setTable(CoreTable table) { this.table = table; }

@PreProcess public void init() {
setCustomers((List) getClientTask().getIoMap().get("customers"));
}

@Validate(choice = "select")
public void validateSelection() {
if (getTable().getSelectedRowData() == null) {
//Message - saying select a value
}
}

@Pack(choice = "select")
public void packSelectedCustomer() {
Object rowData = getTable().getSelectedRowData();
getClientTask().getIoMap().put("selectCustomerReturn", rowData);
}
}
---------------------------
This definetely is very useful enhancement.