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.
work for fun!!!
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.
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
Posted in gmap, Introduction, javascript, web trends
Those who like to fun with coding, hope you will enjoy this variable ![]()

java allows “o_o” as variable name, so isn’t it cute to show an ugly exception
Posted in fun, Introduction, Java
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…
Posted in framework, Introduction, Java, java ee
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.
Posted in Introduction, server
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
Posted in framework, Introduction, Java, java ee
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.
From the left corner:
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.
More depth view of “Online Transaction Service”
thats all for tonight, hope later i will add more stuff
Posted in Ideas, Introduction
Posted in Introduction
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 !!!
Posted in Introduction
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
Posted in Introduction, plugin, wordpress
Recent Comments