Firefox 1.5 with ajax sync request.

This post is to remind myself about a bug on Firefox 1.5.

bug details:

Http ajax request doesn’t invoke “onstatechange” handler if ajax request type is set to sync.

how to resolve this problem:

invoke “onstatechange” function manually.

Google map: map.setCenter(latLng, zoomLevel)

Recently i am playing with Google map. it is really fun. i am thinking i will share my experience through my blog.

problem: i want to set a center point
answer: you can use map.setCenter(new GLatLng(35.746512259918504,-42.1875), 2);
here 35.xxx is lat, -42.xx is lng  and 2 is zoom level.

how to use:

1. you can use “setCenter” when you instantiating an map object. for example:
var map = new GMap2(…);
map.setCenter(..);

2. you can use after completing your initial process. for example:
setCenter after loading marker from GDowloadUrl.

best of luck :)

Variable fun ( o_o )

Those who like to fun with coding, hope you will enjoy this variable :)
variable_fun.gif

java allows “o_o” as variable name, so isn’t it cute to show an ugly exception ;)

A RESTful url using Stripes.

RESTful url may contain the content type with in the url string. For example: http://host/action/xml/bookmark. Here “xml” is content type, this content type can be changed to “text, json” or etc…

So following urls are valid too. http://host/action/text/bookmark, http://host/action/json/bookmark etc…

these days I am playing with “Stripes” web framework a lot. Those who didn’t get in touch with “Stripes” have a look on the following URL – http://stripes.mc4j.org, hope you will enjoy it.

stripes has fantastic flexibility, it enables a lot of customization. Now my tutorial will demonstrate how you can enable this url pattern, where your single “ActionBean” will be invoked on the following url patterns:

http://host/action/xml/bookmark, http://host/action/text/bookmark, http://host/action/json/bookmark etc…

My target audience:
Who has already been introduced with Stripes or those who are interested on stripes framework.

Routing plan:
Request Dispatch
[visitor] —  > http://host/action/xml/bookmark — > [web server] — > [Stripe servlet] — > [Custom Action resolver] — > [remove user defined content type “xml” and retrieve action bean]

Response Dispatch
[clean url (after removing content type)] — > http://host/action/bookmark — > [BookmarkActionBean] — > [Resolution] — >

Pre requisite:
Stripes servlet is configured and web context is up and running.

ActionBean code:
*  create an ActionBean, for example “BookmarkActionBean”

@UrlBinding(“/action/bookmark”)

public class BookmarkAction implements ActionBean {

    private final Log LOG = LogFactory.getLog(getClass());

    private ActionBeanContext mActionBeanContext;

    private String mContentType = “text/xml”;

    public void setContext(ActionBeanContext actionBeanContext) {

        mActionBeanContext = actionBeanContext;

        // retrieve user requested content type constant for example “text,json, xml”

        // convert consts to mime type “text, text/xml, application/JSON”

        mContentType = URLHelper.getMimeType(URLHelper.getContentType(getContext().getRequest().getPathInfo()));

    }

    public ActionBeanContext getContext() {

        return mActionBeanContext;

    }

    @DefaultHandler

    public Resolution save() {

        if (LOG.isDebugEnabled())

            LOG.debug( “storing bookmark object on the data store, ” +

                       “response content type is requested – ” + mContentType );

        return new StreamingResolution( mContentType, new StringReader(“”) );

    }

}

Description:
Here i have set our action on “/action/bookmark” url, but our user requested url pattern is “/action//actionBean”

Look on the “setContext” method, I have added an extra line

mContentType = URLHelper.getMimeType(URLHelper.getContentType(getContext().getRequest().getPathInfo()));

now have a look on the URLHelper class.

public static String getContentType( String pRequestedUrl ) {

        String contentType = CACHED_URL_CONTENT_TYPE.get(pRequestedUrl);

        if (contentType == null) {

            contentType = DEFAULT_CONTENT_TYPE;

            Perl5Util util = new Perl5Util();

            if (util.match( REGEX_ACTION_CONTENT_TYPE, pRequestedUrl ))

                contentType = util.group(1)+”";

            CACHED_URL_CONTENT_TYPE.put( pRequestedUrl, contentType );

        }

        return contentType;

    }

This method is responsible to retrieve user requested content type constants.
for example “text, xml, json”

public static String getMimeType( String pContentType ) {

        // convert content type to MIME Type

        if (pContentType.equalsIgnoreCase(CONTENT_TYPE_CONST_XML))

            pContentType = CONTENT_TYPE_XML;

        else if (pContentType.equalsIgnoreCase(CONTENT_TYPE_CONST_JSON))

            pContentType = CONTENT_TYPE_JSON;

        return pContentType;

    }

This method is also converting constant to MIME content type.
For example “xml –> text/xml”

Now return to my base action bean. I have added the following method, which is defined as default handler.

@DefaultHandler
public Resolution save() {

        ….

        return new StreamingResolution( mContentType, new StringReader(“”) );

    }

Here “mContentType” is repopulate when “setContext” is invoked.

ActionResolver code:
This is my action resolver.

public class NBookmarkSystemActionResolver extends NameBasedActionResolver {

     // ………   

    @Override

    public ActionBean getActionBean(ActionBeanContext pActionBeanContext, String pRequestedUrl) throws StripesServletException {

        String cleanUrl = URLHelper.getCleanUrl(pRequestedUrl);

        if (LOG.isDebugEnabled())

            LOG.debug( “user requested url – ” + pRequestedUrl + ” clean url – ” + cleanUrl);

        return super.getActionBean(actionBeanContext, cleanUrl);

    }

}

Now let’s have a look on “getCleanUrl” method.

public static String getCleanUrl( String pRequestedUrl ) {

        return pRequestedUrl.replaceAll(“/”+getContentType(pRequestedUrl),”");

    }

Custom ActionResolver configuration:

        Stripes Filter

        StripesFilter

        net.sourceforge.stripes.controller.StripesFilter

       

            ActionResolver.UrlFilters

            /WEB-INF/classes/

       

       

            ActionResolver.PackageFilters

            com.we4tech.nBookmarkSystem.service.webService/*

       

       

            ActionResolver.Class

            com.we4tech.nBookmarkSystem.configuration.NBookmarkSystemActionResolver

       

   

That’s all for today,

Hope you will enjoy stripes. Best of luck…

Cache Cache Cache – series 1

hi web crasher,
(it was prepared for http://groups.yahoo.com/group/jpgroup)
(this post is cross published over http://www.somewherein.net/blog/?p=592)
i belief many JPGroup members are utilizing cache in most of the case. in my short post i will show few caching plan and tools.

today, i will highlight on web cache related stuff, let’s imagine we can’t modify our source code, no application level cache. this cache will be maintained separately.

My intended readers are those who didn’t get in touch with web cache related stuffs and those who heard these terms, but didn’t give a try on their project yet.

scene:
Let’s assume “www.nai.com” a site which you have developed, it is a community driven portal, you are expecting 2000 users who will browse this site with in few couple of hours.

so one fine releasing date, you got kicked off, you didn’t expect that you will get around 5000 users with in couple of hours. god damn… you have two severs with distributed session. both are in low latency network. you found your server “A1″ is wasting 50% processor on each request. Obviously lot of tuning over your code is left.

let’s assume, your community site have many aggregation stuffs. for example, the recent user list, the most rated stuffs, most hated stuffs, tag cloud, most comment shit, many things.

obviously, you can’t reduce any feature otherwise it won’t have any difference with other community sites.

so what was happened then, let me continue the story. while your server “A1” was frequently utilizing 50% processor, and your another server “A2” was almost utilizing the same processor, you have heavy database processing and many calculation and many stuffs.

So you have hired a consultant to resolve this problem, now let me pretend what he will do with your project.

preconditions:
You had few preconditions:

1. you can’t change the source or anything won’t be happened over development related stuff.
2. you have been assigned a shortest time, so the consultant has to do it before you dead.
Solutions:
Your hired guy may be happy because of your preconditions, because few stuffs that already helping on this kind of problem.

# Reverse proxy:
[visitor] [proxy server with cache] [application server]
Now how it will help to solve your problem:

1. Visitor won’t get access to your application server,
2. All heavily functional pages will be served from proxy server’s cache
3. proxy server to application connection is in low latency network
What is the changes?
The following changes will boost your community site’s performance.

1. the heavily database or complex logic related functions won’t be executed every time.
2. visitor won’t get 100% up to date data on the fly, perhaps it will take bit longer time based on your cache expire rule.
3. it doesn’t require any code related change.
4. many products and open source stuffs are available on the shelf
5. not suitable for heavily dynamic site, where every second is a change.
6. proxy server can be utilized for load balancing, later you can add more servers.
7. common solution apache with mod_proxy or separate dedicated proxy server. Squid, varnished (which is a modified version of squid proxy server, introduced by linpro)

Have a look on the wiki page, for more proxy server product.
http://en.wikipedia.org/wiki/Reverse_proxy

# OSCache servlet filter
This is another alternative solution, it will require few changes on “web.xml” file.
You have to put a OSCache filter servlet, which will cache each and every unique request. For expiring all these cache you can set up the cache expire event.

OSCache servlet filter is easy to use, and you can write your cache expire rule on a java class. As it is not the change on your core system, so no conflict with your preconditions.

# Oracle web cache
Oracle has reverse proxy type solution which they have labeled as “Web cache”
It can scale your community site, it had coupling with oracle application server. So if your application server is oracle$ application server, you can give a try.
That’s all for today.
Best wishes for those who died 21st February to bring our mother tongue.

Nice Stripes web framework

hi,
at least i could manage some time to write about Stripes (http://stripes.mc4j.org/)

stripes is a web framework, it has very few dependencies, configuration over convention is highly adopted on Stripes.

you don’t need to bother about any separate XML file or properties file, it is as simple as web.xml servlet configuration. just put your all configuration over

more over it has default convention centric url discovery… for example “HelloAction”.. this action can be accessed over “http:///Hello.htm” or whatever u map on url mapping.

very flexible system. it has very simple work flow management, (who already familiar with JSF navigation or Spring web flow will be interested on its work flow)

by default it has multi action on each class, and you can override the url or any settings over @annotation. which is the most powerful feature over stripes.

web form validation is one of the nice and simple approaches over stripes. i am really loving it..
you can apply validation rule over @annotation. here is few example.. hope it will give you clean understanding.

@ValidateNestedProperties({
@ValidateNestedProperties({
@Validate( field = “accountName”, required = true, on = {“register”}),
@Validate( field = “password”, required = true, minlength = 6, on = {“register”})})
private User user;

@Validate( expression = “user.password == this”, on = “register”, required = true)
private String confirmPassword;

it has support over spring container, so spring developer won’t get you out…

best wishes…

http://hasan.we4tech.com

Online Money transaction – nightmare

I was reading through this blog post, which is nicely written by Tanvir. He represents a very nice idea.

Here I am going to represent my idea, based on my experience on online presence and web based application development. This article will more on graphical presentation rather writing the textual content, more over I am not good in writing.

My overall plan is shown in the following picture.

online_trx_1.jpg my proposed Online Transaction Model

From the left corner:

  1. online users, who wants to buy stuffs (user)
  2. the service providers who want to sell their stuffs (merchant)
  3. a service bridge between 3rd party online transaction service provider and merchant
  4. online transaction service provider
  5. relation with 3rd party insurance and mortgage company
  6. common protocol to connect with local banks

Interaction among the user, merchant and service domains:

Let’s think a user “Miss. nai”, who is interested to buy a book “abc” from “boi-mela.com”. now let’s imagine the interactions among the services.

online_trx_2.jpg Interaction among the services (1st party, 2nd party and 3rd party)
  1. user > boi-meal.com: “I wanna buy ‘abc’ book”
  2. boi-meal.com > user: “give me your secret code”
  3. boi-meal.com > OTS: “she wanna buy some stuffs…” [send secret code to OTS]
  4. OTS > boi-meal.com: “you can trust, she has an account with me”
  5. boi-meal.com > OTS: “can she transfer 300 tk. To my account?”
  6. OTS > boi-meal.com: “sure she has sufficient balance, cheers!!”
  7. boi-meal.com > user: “can you give your identification code, which was given after your previous transaction?”
  8. user > boi-meal.com: “Ohh, yea, here is it… ****”
  9. boi-meal.com > OTS: “can you please transfer 300 tk. Here is her unique identification code”
  10. OTS < boi-meal.com: “Wow!!, that’s valid, you got her balance now”
  11. OTS < boi-meal.com: “Anyway, let her know about her, new transaction id and identification code”
  12. user < boi-meal.com: “Yahoo!!, transaction done, thank you for your patient”

More depth view of “Online Transaction Service”

online_trx_3.jpg OTS in depth
  1. merchant & user detection
    verify whether user request is coming from valid and trusted merchant. Also verify whether user, who wants to buy stuff, is already subscribed with “Online Transaction Service”.

  2. ensure escort money from user account
    when transaction has began, OTS will escort few balance from user account. To ensure perfect transaction between merchant and user.

  3. alternatively, ensure insurance for each transaction
    OTS can hook up with 3rd party insurance company, which company will ensure insurance for each and every transactions. In this case OTS has to buy insurance policy. It will affect merchant, they have to pay few additional service charge. But no impact for end user.

  4. validate user account or balance
    verify user presence over ”Common protocol”, where Common Protocol will communicate with all local (subscribed) banks or Credit Card authority through comprehensive web service.

  5. notify Account transfer
    local (subscribed) banks or CC authority will notify status of account transfer through ”Common protocol”.

  6. receive balance transfer confirmation from user bank
    user has to confirm their balance transfer, hereafter successful transaction, a new identification code will be generated, which can be used for single transaction.

  7. receive balance transfer confirmation from merchant bank

thats all for tonight, hope later i will add more stuff

Protected: E-card

Only invited people are accepted
EiD Card for SE 2006 - 30-12-2006

OpenSearch: How to add Search Engine on FireFox 2

hi,
let’s think you have a web site, which provides lot of information. you have searching feature for your visitor…
do you want to add your Search engine on your visitor’s FireFox browser?

hope you surely want…

STEP 1:
——————-
(#) File: osd.xml

<OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/”>
<ShortName>swi issue tracker</ShortName>
<Description>somewhere in… issue tracker</Description>
<Contact>hasan@somewherein.net</Contact>
<Url type=”text/html” method=”get” template=”http://www.somewherein.net/issues/view.php?id={searchTerms}”>
</Url>
<LongName>somewhere in… issue tracker</LongName>

<Image height=”32″ width=”32″ type=”image/vnd.microsoft.icon”>http://hasan.we4tech.com/issuetracker.ico</Image>
<Image height=”16″ width=”16″ type=”image/png”>http://hasan.we4tech.com/issuetracker.png</Image>
<Image height=”16″ width=”16″ type=”image/vnd.microsoft.icon”>http://hasan.we4tech.com/issuetracker.ico</Image>
<Query role=”example” searchTerms=”issuetracker”/>
<Developer>nhm tanveer hossain khan (hasan)</Developer>
<Attribution>
Search data © 2006, somewhere in…, No Rights Reserved.
</Attribution>

<SyndicationRight>open</SyndicationRight>
<AdultContent>false</AdultContent>
<Language>en-us</Language>
<OutputEncoding>UTF-8</OutputEncoding>
<InputEncoding>UTF-8</InputEncoding>
</OpenSearchDescription>

STEP 2:
——————————-
add the following code in your HTML > Head tag block

<link title=”Somewhere in… Issue tracker Search” type=”application/opensearchdescription+xml” rel=”search” />

Let’s Rock !!!

Fitness Indicator v 0.2.2

Yahoo!!!. Now fitness indicator is more customizable…

Have a look on the changes list of version 0.2.2

v-0.2.2
——————————————-

1. resolved Header already sent bug

2. added more flexible way to handle your fitness indicator

3. get_health_meter_object() returns Fitness indicator object

Download here…

Do you want to see in reverse order?

my tweets

  • @ReDrUmNZ after increasing buffer to 2 mins it's all gone. 1 week ago
  • @ReDrUmNZ i had a video wall kinda thing where around 6 small live streams were auto playing, due to 0 buffer it was leaking sound "hizzsss" 1 week ago
  • @ReDrUmNZ fyi, hi i got that video hissing things solved. it was due to buffer :) 1 week ago
  • lesson learned #Android #html5 #VIDEO doesn't work if you have none supported source 1 month ago
  • @ReDrUmNZ hi i'm using several VideoDisplay and a big VideoPlayer for showing whenever those are dbl clicked. do u think it has reltn too ? 1 month ago

 

May 2012
S S M T W T F
« Aug    
 1234
567891011
12131415161718
19202122232425
262728293031  

Flickr Photos

Beauty Lassi and Faluda - http://www.khadok.com/t/restaurants/beauty-lassi-and-faluda-old-dhaka/65?l=en

Beauty Lassi and Faluda - http://www.khadok.com/t/restaurants/beauty-lassi-and-faluda-old-dhaka/65?l=en

Khazana http://www.khadok.com/t/restaurants/khazana-a-treasure-of-indian-cuisine/249?l=en

Khazana http://www.khadok.com/t/restaurants/khazana-a-treasure-of-indian-cuisine/249?l=en

Khazana http://www.khadok.com/t/restaurants/khazana-a-treasure-of-indian-cuisine/249?l=en

More Photos
Follow

Get every new post delivered to your Inbox.