Tuesday 16 August 2016

Java - Extract data between html tags

/**
* This function helps in getting contents spans html tag;
* For ex., <body><b>Sample Text</b></body> will result in <b>Sample Text</b>
* @param content html content;
* @param startTag starting tag with html content, Ex., <body
* @param endTag ending tag Ex., </body>
* @return String
*/
public static String getPartialHtmlContent(String content, String startTag, String endTag) {
int startIndex = content.indexOf(startTag);
//Tag might contain attributes
startIndex = content.indexOf(">", startIndex);
int endIndex = content.indexOf(endTag);

if(startIndex > 1 && endIndex > 1)
return content.substring(startIndex + 1, endIndex);
return content;
}
Read More

Monday 18 January 2016

MyEclipse editor is slow on xhtml

Editing xhtml files with MyEclipse is horribly slow.

Couple of tweaks can help on this:

1. Disable unused plugins(From Windows --> Preferences)



2. Remove validations on runtime(From Windows --> Preferences)



3. Open file either in 'Html Editor' or even in text editor(if you prefer so):


Enjoy Coding :-)
Read More

Saturday 19 December 2015

MySQL Error Number 1005 Can’t create table (errno: 150)

Despite having proper  column mappings and type, when you are unable to establish foreign key relationship, look for 'Engine' they belonging to:


In this scenario, 'InnoDB' is the engine for both tables.
Read More

Mysql - Map users to access schema

Grant all privilege to user for all tables

GRANT ALL PRIVILEGES ON <schema_name>.* TO '<user>'@'%' WITH GRANT OPTION;
Read More

Monday 24 March 2014

Java:: Calculate method execution time

Quite often performance is a huge threat to any application. To isolate certain method call taking time, for instance in my case JCR session acquiring takes time.

To calculate time difference, use 'System' api function.

// Place at the start of method execution
final long startTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
// Process....

//Before end of method
final long endTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());

System.out.println("Time taken :::: " + (endTime - startTime)+ "seconds");


If you have Spring AOP support in your application, you can configure this pattern with required methods.




Read More

Tuesday 28 February 2012

Subtleties of Dojo

RIA framework Dojo has rich set of Widgets and Data store capabilities.
But lack in documentation really makes painful to work with Dojo.

I will write on how to make CRUD using DOJO and Spring soon.
Read More

About Me

Popular Posts

Designed ByBlogger Templates