<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;C08EQHc4cSp7ImA9WhRaEUo.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230</id><updated>2012-02-13T16:23:21.939-06:00</updated><category term="Bonds" /><category term="SQL" /><category term="hotkey plus" /><category term="junit" /><category term="selenium" /><category term="mimetype" /><category term="ImageMagic" /><category term="htmleditor" /><category term="jar" /><category term="Insurance" /><category term="CTRL + BREAK" /><category term="job" /><category term="lsof" /><category term="similar columns" /><category term="counter offer" /><category term="grep" /><category term="performance" /><category term="sabeer bhatia" /><category term="Executors" /><category term="JRE 1.6.0_19" /><category term="Brother printer" /><category term="ExtJS" /><category term="newCachedThreadPool" /><category term="JAWR" /><category term="java" /><category term="compensation" /><category term="mysql" /><category term="Tuning. ThreadDump" /><category term="subeclipse" /><category term="MFC490CW" /><category term="BDB Replication" /><category term="CACHE_VERSION" /><category term="cloud" /><category term="thumbnail" /><category term="oracle" /><category term="Axis bank" /><category term="exec" /><category term="mod_ssl" /><category term="newFixedThreadPool" /><category term="echo" /><category term="interceptor" /><category term="sign" /><category term="optimization" /><category term="Time management" /><category term="TM contention" /><category term="bean" /><category term="Python" /><category term="Queue" /><category term="PIL" /><category term="whitespace" /><category term="proxy" /><category term="Aggregating" /><category term="Exchange" /><category term="dual" /><category term="AJAX" /><category term="slowness" /><category term="locator pattern" /><category term="Stock market" /><category term="Tiff" /><category term="Build" /><category term="Keyboard" /><category term="SmartClient" /><category term="Programmer" /><category term="opensource" /><category term="being lazy" /><category term="tuning" /><category term="DWR" /><category term="RabbitMQ" /><category term="job security" /><category term="AMQP" /><category term="Office 2007" /><category term="Java HttpServer" /><category term="Spring" /><category term="timestamp" /><category term="ThreadDump" /><category term="Quartz Admin" /><category term="purge" /><category term="similar constraints" /><category term="ant" /><category term="recession" /><category term="REST" /><category term="JSR311" /><category term="prank" /><category term="pattern matching" /><category term="paul graham" /><category term="JDK proxy" /><category term="tika" /><category term="expired certificate" /><category term="CGLib" /><category term="Silicon valley" /><category term="index" /><category term="IE" /><category term="windows7" /><category term="YSlow" /><category term="schema diff" /><category term="OutOfMemory" /><category term="Applet" /><category term="beginner" /><category term="CMYK" /><title>Programming fun at startup</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://neopatel.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>125</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/ProgrammingFunAtStartup" /><feedburner:info uri="programmingfunatstartup" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CkANRnY_eSp7ImA9WhRaEE8.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-2863287678907673760</id><published>2012-02-11T22:26:00.000-06:00</published><updated>2012-02-11T22:26:37.841-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-11T22:26:37.841-06:00</app:edited><title>Client side autocomplete searches</title><content type="html">I was looking for an autocomplete for an addressbook kind of functionality. The requirement was that users can have FirstName,LastName,Email,Type and when user starts typing they need to be searched first by LastName,FirstName,Email and some types were to be given higher priority than others. Doing this on server side means too many calls to be sent to the server so doesnt seems like a perfect solution.&amp;nbsp; Also mostly users will have &amp;lt;100-1000 contacts in addressbook so why not do it on client side.&amp;nbsp; Looked into some autocomplete plugins but none of them were what I wanted and finally landed onto this &lt;a href="http://code.flickr.com/blog/2009/03/18/building-fast-client-side-searches/"&gt;http://code.flickr.com/blog/2009/03/18/building-fast-client-side-searches/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I have never found such a perfect solution to a complex problem before. Thanks flickr for sharing it ;).&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-2863287678907673760?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/NOEBCR3icClk0vP3vHj0CRlhlBY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/NOEBCR3icClk0vP3vHj0CRlhlBY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/NOEBCR3icClk0vP3vHj0CRlhlBY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/NOEBCR3icClk0vP3vHj0CRlhlBY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/gArWHIxwBOw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/2863287678907673760/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2012/02/client-side-autocomplete.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/2863287678907673760?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/2863287678907673760?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/gArWHIxwBOw/client-side-autocomplete.html" title="Client side autocomplete searches" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2012/02/client-side-autocomplete.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0AERHw6eCp7ImA9WhRbFUQ.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-6897601346272784641</id><published>2012-02-06T23:15:00.000-06:00</published><updated>2012-02-06T23:15:05.210-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-06T23:15:05.210-06:00</app:edited><title>Mysql JDBC driver and Streaming large resultset</title><content type="html">We are moving one legacy component from Berkeley db to mysql so that we can replicate it to distribute read requests and shard it to scale it. I had to dump the entire db contents and stream it over http to some other component. the db content for a single customer can range from 100K to 3-4 Million records. We are using spring JDBC to make the task of dealing with jdbc api simple. Now I was using a ResultSetExtractor to stream the resultset like this.&lt;br /&gt;
&lt;br /&gt;
&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ResultSetExtractor&lt;object&gt; resultSet = new ResultSetExtractor&lt;object&gt;() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public Object extractData(ResultSet result) throws SQLException, DataAccessException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; while(result.next()){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; XXXXX&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return "";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;
&lt;span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span&gt;getJdbcTemplate(context).getJdbcOperations().query( sql, resultSetExtractor);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
But it appears that Mysql native JDBC driver loads entire resultset into memory before passing the control onto ResultSetExtractor and that was causing OOM.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq" style="font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;

            By default, ResultSets are completely retrieved and stored
            in memory. In most cases this is the most efficient way to
            operate, and due to the design of the MySQL network protocol
            is easier to implement. If you are working with ResultSets
            that have a large number of rows or large values, and cannot
            allocate heap space in your JVM for the memory required, you
            can tell the driver to stream the results back one row at a
            time.
          &lt;br /&gt;

            To enable this functionality, create a
            &lt;code class="literal"&gt;Statement&lt;/code&gt; instance in the following
            manner:
          &lt;br /&gt;
&lt;pre class="programlisting"&gt;stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,
              java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);&lt;/pre&gt;
The combination of a forward-only, read-only result set,
            with a fetch size of &lt;code class="literal"&gt;Integer.MIN_VALUE&lt;/code&gt;
            serves as a signal to the driver to stream result sets
            row-by-row. After this, any result sets created with the
            statement will be retrieved row-by-row.
          &lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
This is explained here &lt;a href="http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-implementation-notes.html%20" target="_blank"&gt;&lt;span&gt;http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-implementation-notes.html&lt;/span&gt;&amp;nbsp;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
It seems SimpleJdbcTemplate doesnt have a setFetchSize method and JdbcTemplate has a setFetchSize but that doesn not work when you call the query method and if you use statement then the applySettings method applies fetchSize only if its &amp;gt;0.&amp;nbsp; So the solution is to use PreparedStatement directly&lt;br /&gt;
&lt;br /&gt;
callback = new PreparedStatementCallback&lt;void&gt;() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public Void doInPreparedStatement(PreparedStatement pstmt) throws SQLException, DataAccessException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ResultSet rs = pstmt.executeQuery();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; resultSetExtractor.extractData(rs);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; rs.close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/void&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; executeStreamed(jdbcTemplate, callback, sql);&lt;br /&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-implementation-notes.html&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* Unless you specify the statement settings as below the mysql driver is going to load all results in memory.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* @param jdbcTemplate&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* @param callback&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* @param sql&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected void executeStreamed(SimpleJdbcTemplate jdbcTemplate, PreparedStatementCallback&lt;void&gt; callback, final String sql) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; PreparedStatementCreator creator = new PreparedStatementCreator() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public PreparedStatement createPreparedStatement(Connection conn) throws SQLException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; PreparedStatement pstmt = conn.prepareStatement(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; java.sql.ResultSet.CONCUR_READ_ONLY);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; pstmt.setFetchSize(Integer.MIN_VALUE);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return pstmt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; jdbcTemplate.getJdbcOperations().execute(creator, callback);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;/void&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/object&gt;&lt;/object&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-6897601346272784641?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/GvXXtq1BIxuYwbw9s8mNe2zV37E/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GvXXtq1BIxuYwbw9s8mNe2zV37E/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/GvXXtq1BIxuYwbw9s8mNe2zV37E/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GvXXtq1BIxuYwbw9s8mNe2zV37E/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/YNjjDiOMiJ4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/6897601346272784641/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2012/02/mysql-jdbc-driver-and-streaming-large.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/6897601346272784641?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/6897601346272784641?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/YNjjDiOMiJ4/mysql-jdbc-driver-and-streaming-large.html" title="Mysql JDBC driver and Streaming large resultset" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2012/02/mysql-jdbc-driver-and-streaming-large.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8HSH8yfCp7ImA9WhRbFUU.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-5622814588568959696</id><published>2012-02-06T22:27:00.000-06:00</published><updated>2012-02-06T22:27:19.194-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-06T22:27:19.194-06:00</app:edited><title>self signed certificates and chrome caching</title><content type="html">Ran into an issue today where despite setting cache tags on a swf file,&amp;nbsp; the chrome browser was downloading it everytime I moved from one page to other and come back to same page. This was working fine in Internet Explorer and FireFox.&amp;nbsp; After spending an hour with firebug, pagespeed and fiddler&amp;nbsp; I figured out that cache tags were set correctly but still chrome won't cache it. At last I found this issue reported to chrome developers &lt;a href="http://code.google.com/p/chromium/issues/detail?id=103875"&gt;http://code.google.com/p/chromium/issues/detail?id=103875&lt;/a&gt; .&amp;nbsp; It appears that because&amp;nbsp; I was using a self signed certificate on local install, chrome wont cache any content until I use a valid certificate.&amp;nbsp; So the solution is to generate a free certificate using &lt;a href="https://www.startssl.com/"&gt;https://www.startssl.com/&lt;/a&gt; and use it locally to avoid this issue.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-5622814588568959696?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ma88iFp2hnX9I00vfnWSG2lwFYk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ma88iFp2hnX9I00vfnWSG2lwFYk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ma88iFp2hnX9I00vfnWSG2lwFYk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ma88iFp2hnX9I00vfnWSG2lwFYk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/3aPOo9TcRX8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/5622814588568959696/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2012/02/self-signed-certificates-and-chrome.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/5622814588568959696?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/5622814588568959696?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/3aPOo9TcRX8/self-signed-certificates-and-chrome.html" title="self signed certificates and chrome caching" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2012/02/self-signed-certificates-and-chrome.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8ARHY8fCp7ImA9WhRbEUg.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-2405673439607767005</id><published>2012-02-01T22:44:00.000-06:00</published><updated>2012-02-01T22:44:05.874-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-01T22:44:05.874-06:00</app:edited><title>Sharing between Andriod phone and ubuntu</title><content type="html">I dont want to install facebook on my phone and I wanted to share some pics so had I a requirement to copy some pictures taken from my phone to my ubuntu drive. This assumes your android and laptop are on same wifi network. It seems its very easy to do it and we would use samba share to do it.&lt;br /&gt;
&lt;br /&gt;
1) Install AndSMB app on andriod phone.&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
2) create a folder on your ubuntu server and Right click on it and say Share this folder as shown below.&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-IcNRQmLNWHI/TyoTmgzGdDI/AAAAAAAAB64/Hzux0R_wxzU/s1600/sharing.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/-IcNRQmLNWHI/TyoTmgzGdDI/AAAAAAAAB64/Hzux0R_wxzU/s320/sharing.png" width="240" /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-YCNJ_RqMO5A/TyoTn4_6t3I/AAAAAAAAB7A/D60Iv3C1FBs/s1600/share+perm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="142" src="http://2.bp.blogspot.com/-YCNJ_RqMO5A/TyoTn4_6t3I/AAAAAAAAB7A/D60Iv3C1FBs/s320/share+perm.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
3) Connect to this share from your android by using the smb app and give your username/password and leave the domain blank.&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
4) Now you can navigate to the samba share folder and select the files to upload.&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-2405673439607767005?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/po8pePfiiNdPXQz2mwkoewZJ2WI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/po8pePfiiNdPXQz2mwkoewZJ2WI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/po8pePfiiNdPXQz2mwkoewZJ2WI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/po8pePfiiNdPXQz2mwkoewZJ2WI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/z6yMr41VhWc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/2405673439607767005/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2012/02/sharing-between-andriod-phone-and.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/2405673439607767005?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/2405673439607767005?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/z6yMr41VhWc/sharing-between-andriod-phone-and.html" title="Sharing between Andriod phone and ubuntu" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-IcNRQmLNWHI/TyoTmgzGdDI/AAAAAAAAB64/Hzux0R_wxzU/s72-c/sharing.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2012/02/sharing-between-andriod-phone-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8CR3szfyp7ImA9WhRVFko.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-3696921188934277672</id><published>2012-01-15T19:37:00.001-06:00</published><updated>2012-01-15T19:37:46.587-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-15T19:37:46.587-06:00</app:edited><title>Carrying over Log4j context in threadpool</title><content type="html">We use MDC feature of slf4j/log4j to automatically log the details about user/client that is making the request so we can trace the things happening in the thread.&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void setRequestId(String requestId) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (requestId != null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MDC.put("MDC_REQUEST_ID", requestId);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MDC.put("MDC_REQUEST_ID", "");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void setUserInContext(long userId) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MDC.put("MDC_USER_ID", String.valueOf(userId));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
and the log4j appender users&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;appender name="RFA_ROOT" class="org.apache.log4j.rolling.RollingFileAppender"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;param name="FileNamePattern" value="${catalina.base}/logs/kp.log.%d{yyyy-MM-dd-HH}"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;param name="ActiveFileName" value="${catalina.base}/logs/kp.log"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/rollingPolicy&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;layout class="org.apache.log4j.PatternLayout"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;param name="ConversionPattern" value="%p %d{ISO8601} %t D-%X{MDC_DOMAIN} U-%X{MDC_USER_ID} S-%X{MDC_SYNC_CID} R-%X{MDC_REQUEST_ID} %c - %m%n"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/layout&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/appender&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will automatically print User and request Id but when you want to get the user requests funnel through some threadpool to avoid thundering herd problem then the log4j context is not carried over and this breaks traceability. To solve this problem the easy solution is to just create your own Callable and use that in thread pool.&lt;br /&gt;
&lt;br /&gt;
public abstract class MyCallable&lt;t&gt; implements Callable&lt;t&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Map contextMap = AppLogger.getCopyOfContextMap();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public T call() throws Exception {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MDC.setContextMap(contextMap);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return internalCall();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } finally {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MDC.clear();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected abstract T internalCall() throws Exception;&lt;br /&gt;&lt;br /&gt;}&lt;/t&gt;&lt;/t&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MyCallable&lt;string&gt; task = new MyCallable&lt;string&gt;() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public String internalCall() throws Exception {&lt;br /&gt;...&lt;/string&gt;&lt;/string&gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;
&lt;br /&gt;
and use&lt;br /&gt;
SpringBeanLocator.getRestRequestHelper().getRestRequestExecutors().submit(task);&lt;br /&gt;
&lt;br /&gt;
This way your context would be carried over to background threads.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-3696921188934277672?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/uvLX3XKZ_lLiXNbDAb_QhI6zPjo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/uvLX3XKZ_lLiXNbDAb_QhI6zPjo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/uvLX3XKZ_lLiXNbDAb_QhI6zPjo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/uvLX3XKZ_lLiXNbDAb_QhI6zPjo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/270vWpowV7U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/3696921188934277672/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2012/01/carrying-over-log4j-context-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/3696921188934277672?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/3696921188934277672?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/270vWpowV7U/carrying-over-log4j-context-in.html" title="Carrying over Log4j context in threadpool" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2012/01/carrying-over-log4j-context-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QHQX4-eip7ImA9WhRVFko.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-7054636719689391996</id><published>2012-01-15T18:55:00.000-06:00</published><updated>2012-01-15T18:55:30.052-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-15T18:55:30.052-06:00</app:edited><title>smartsprite to generate sprite automatically</title><content type="html">I am a lazy person and like to automate things that can be automated. We had all our sprites hand written earlier and the problem with that approach is that it was append only. Every time you have to add a new image the developer would add it at the end but if I asked to remove an image then they would give me a look like what the heck I am talking about, they would give weeks estimate to go and fix coordinates in each and every place those images were used. Net net this seems like something that should not be that hard to automate and thats where smartsprite came to rescue. A very very handy tool to automatically generate your sprite and biggest benefit is that its non-intrusive and you can start small and keep cleaning your old code and convert to this mode as and when you change that part of code.&amp;nbsp;&amp;nbsp; This is the link to the tool &lt;a href="http://csssprites.org/"&gt;http://csssprites.org/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
So all you need to do is add some comments at the top of&amp;nbsp; your existing css&lt;br /&gt;
/** sprite: kpSmartSprite; sprite-image: url('../images/kpSmartSprite-${md5}.png'); sprite-layout: vertical; */&lt;br /&gt;
&lt;br /&gt;
and then the css rule where you add image reference you have to add the comment&lt;br /&gt;
&lt;br /&gt;
.t-add { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; background-image: url("../images/add.png") !important;&amp;nbsp; /** sprite-ref: kpSmartSprite;&amp;nbsp; sprite-alignment: left;&amp;nbsp; sprite-margin-bottom:6px;*/ &lt;br /&gt;}&lt;br /&gt;
&lt;br /&gt;
So you can keep adding these tags. Now you can use an ant target to generate your sprite. The tool will generate the sprite image and will also change you css file to add the coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;target name="sprite-images" description="Creates a sprite using smartsprite by reading smart sprite annotations"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;taskdef resource="smartsprites.xml"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;classpath&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fileset dir="${thirdParty}/tools/smartsprites-0.2.8/lib"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;include name="*.jar" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/fileset&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/classpath&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/taskdef&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;smartsprites rootdir="${war.path}/css"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; documentrootdir=""&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputdir="${war.path}/css-sprite"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cssfileencoding="UTF-8"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cssfilesuffix=""&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loglevel="INFO"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spritepngdepth="AUTO"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spritepngie6="false" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;move todir="${war.path}/css" failonerror="no"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fileset dir="${war.path}/css-sprite" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/move&amp;gt;&lt;br /&gt;&amp;lt;/target&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-7054636719689391996?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/I1pxhwR7fpU9AkZ-uQP1QBQNO_s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/I1pxhwR7fpU9AkZ-uQP1QBQNO_s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/I1pxhwR7fpU9AkZ-uQP1QBQNO_s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/I1pxhwR7fpU9AkZ-uQP1QBQNO_s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/uCreW7WZd7Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/7054636719689391996/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2012/01/smartsprite-to-generate-sprite.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/7054636719689391996?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/7054636719689391996?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/uCreW7WZd7Y/smartsprite-to-generate-sprite.html" title="smartsprite to generate sprite automatically" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2012/01/smartsprite-to-generate-sprite.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkAGQXs4eip7ImA9WhRREEw.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-7650592858068436299</id><published>2011-11-20T09:35:00.001-06:00</published><updated>2011-11-22T21:25:20.532-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-22T21:25:20.532-06:00</app:edited><title>Advantages of working remote</title><content type="html">There are many &lt;a href="http://neopatel.blogspot.com/2011/11/disadvantages-of-working-remote.html"&gt;disadvantages of working remote&lt;/a&gt;&amp;nbsp; but there are many advantages of working remote.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;You are saving time on commute so you get more time for family if you are disciplined enough to start/stop work at office times (rarely happens on all days but still better than getting stuck in traffic)&lt;/li&gt;
&lt;li&gt;Less people coming and distracting you by just walking into cubicle to discuss office politics&lt;/li&gt;
&lt;li&gt;Less people coming and asking you things that they can just google for themeselves.&lt;/li&gt;
&lt;li&gt;Due to the above points you get more work done in less amount of time.&lt;/li&gt;
&lt;li&gt;You &lt;a href="http://en.wikipedia.org/wiki/RTFM" target="_blank"&gt;RTFM&lt;/a&gt; more than usual. If you are stuck on an issue you are the only one who can find the solution as the luxary of walking into someone's cubicle for help is gone, In a sense its a double edged sword but as you are left with no choice in the end you come up as winner and you become more and more of problem solver on your own. This way you tend to research things in detail and increase your arsenal of skills. &lt;/li&gt;
&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-7650592858068436299?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/QK2bbim0G0Tx0I4abnJPdx_oNB4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QK2bbim0G0Tx0I4abnJPdx_oNB4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/QK2bbim0G0Tx0I4abnJPdx_oNB4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QK2bbim0G0Tx0I4abnJPdx_oNB4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/d46x5GygCZs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/7650592858068436299/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/11/advantages-of-working-remote.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/7650592858068436299?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/7650592858068436299?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/d46x5GygCZs/advantages-of-working-remote.html" title="Advantages of working remote" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/11/advantages-of-working-remote.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MBSHY6fCp7ImA9WhRSE0Q.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-7792690894449457872</id><published>2011-11-15T17:15:00.001-06:00</published><updated>2011-11-15T17:24:19.814-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-15T17:24:19.814-06:00</app:edited><title>openoffice and NFS file saving issue</title><content type="html">I recently integrated a file preview application in our application with team, so now users can preview most of the files without downloading them. The hard part was to deal with NFS issues due to locking and caching. We chose to buy v/s build for the file preview and bought some third party service. The third party service lets call it APreview had a http api where you can pass the source and target file path. It would have been much better if we could stream the input and it could stream the output but that option was not there. Because we can only pass paths to it the natural solution was to use NFS paths. So we ran into two major issues:&lt;br /&gt;
&lt;br /&gt;
1)The APreview application internally uses openoffice to convert word/PPT/Xls files to pdf and then it converts pdf to swf. openoffice has some issues with writing to NFS and we could use vi and other tools to write files but openoffice would just refuse to save the file as pdf. Finally I found that commenting these two lines in /usr/lib64/openoffice.org3/program/soffice made the thing working&lt;br /&gt;#SAL_ENABLE_FILE_LOCKING=1&lt;br /&gt;#export SAL_ENABLE_FILE_LOCKING&lt;br /&gt;
&lt;br /&gt;
you have to comment it out. setting this SAL_ENABLE_FILE_LOCKING=0 wont work and dont forget to comment out the 'export' also.&lt;br /&gt;
&lt;br /&gt;
2) Serving file over NFS had issues because of NFS cache lag. The VM where APreview was installed would write the file on NFS mount but the tomcat that has to serve the file was seeing the file after 15 sec delay. We tried all sort of things and ultimately gave up on NFS to serve the file. We installed apache on the Filer-server where preview were stored and served the file over http using apache reverse proxy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-7792690894449457872?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sybNecHLFADrzbVrmNhETnj1wQc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sybNecHLFADrzbVrmNhETnj1wQc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sybNecHLFADrzbVrmNhETnj1wQc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sybNecHLFADrzbVrmNhETnj1wQc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/3Q9p-sfNK2o" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/7792690894449457872/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/11/openoffice-and-nfs-file-saving-issue.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/7792690894449457872?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/7792690894449457872?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/3Q9p-sfNK2o/openoffice-and-nfs-file-saving-issue.html" title="openoffice and NFS file saving issue" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/11/openoffice-and-nfs-file-saving-issue.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMESX05eyp7ImA9WhRWF0w.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-585513831011368883</id><published>2011-11-15T15:23:00.001-06:00</published><updated>2012-01-04T16:33:28.323-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-04T16:33:28.323-06:00</app:edited><title>Disadvantages of working remote</title><content type="html">Just ranting it out loud, I am working remote for the past two years for a startup and there are many advantages of working remote but there are many disadvantages also.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Its hard to chase people over phone. As people wont pick up the call or they wont reply to Instant Messages. So you are stuck in your chain of thoughts cursing the monitor.&lt;/li&gt;
&lt;li&gt;You miss the coffee talk.&lt;/li&gt;
&lt;li&gt;You miss what's going on in the office and really dont know whats going in the company.&lt;/li&gt;
&lt;li&gt;In meetings you could be writing code and its easy to get distracted over phone.&lt;/li&gt;
&lt;li&gt;Some people prefer to chat over talk and thats a pain because you already miss the social connection and typing is always a pain.&lt;/li&gt;
&lt;li&gt;You miss all company dinners and lunches.&lt;/li&gt;
&lt;li&gt;Because you save time on travel you tend to overwork.&lt;/li&gt;
&lt;li&gt;Worse if you are working in a different timezone then people would disturb you off hours.&lt;/li&gt;
&lt;li&gt;Lots of time is spent in trying to screen share or do go to meeting.&lt;/li&gt;
&lt;li&gt;People will prefer to talk to person in house and unless you are a rockstar and only you can deliver the feature mostly people will prefer in house person.&lt;/li&gt;
&lt;li&gt;Lots of things will get discussed in adhoc passageway meeting and you would miss all of that.&lt;/li&gt;
&lt;li&gt;Dealing with HR is a pain. As you are remote you dont have the luxary of walking into their cube and getting your work done. I am literally screwed on every work that needs to flow through HR. Communicating with them on email leads to frustration and all you can do is curse your monitor.&lt;/li&gt;
&lt;/ul&gt;
Also check my post on &lt;a href="http://neopatel.blogspot.com/2011/11/advantages-of-working-remote.html"&gt;Advantages of working remote &lt;/a&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-585513831011368883?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tkJeGWQs2NVQZpNLUEFPgiWXHbQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tkJeGWQs2NVQZpNLUEFPgiWXHbQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tkJeGWQs2NVQZpNLUEFPgiWXHbQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tkJeGWQs2NVQZpNLUEFPgiWXHbQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/UYa8T-G4ego" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/585513831011368883/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/11/disadvantages-of-working-remote.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/585513831011368883?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/585513831011368883?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/UYa8T-G4ego/disadvantages-of-working-remote.html" title="Disadvantages of working remote" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/11/disadvantages-of-working-remote.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMHQnc-fip7ImA9WhRTFEs.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-983802465891407658</id><published>2011-11-04T23:13:00.002-05:00</published><updated>2011-11-04T23:13:53.956-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-04T23:13:53.956-05:00</app:edited><title>Jesey writing an authentication filter</title><content type="html">It seems there are two ways to add authentication to Jersey REST apis&lt;br /&gt;
&lt;br /&gt;
1) You can add a servlet filter.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;public class RestAuthenticationFilter implements Filter {
&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void destroy() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // TODO Auto-generated method stub&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; try {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; User user = BasicAuthHelper.authenticateUser(request);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (user == null) {
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;} else {
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;request.setAttribute("user", user);
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chain.doFilter(request, response);
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}
 &amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (ApplicationException e) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void init(FilterConfig config) throws ServletException {
&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
} 
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
2) You can do it using the jersey filter. You have to implement a ResourceFilterFactory and handle the auth in ContainerRequestFilter. The detailed code is below.&amp;nbsp; I like the approach 1 as it give complete lifecycle control. However if you need more specifc things like accessing QueryParams or PathParams then approach 2 is the way to go&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
public class RestAuthFilterFactory implements ResourceFilterFactory {
&amp;nbsp;&amp;nbsp;&amp;nbsp; private static final AppLogger logger = AppLogger
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .getLogger(RestAuthFilterFactory.class);

&amp;nbsp;&amp;nbsp;&amp;nbsp; @Context
&amp;nbsp;&amp;nbsp;&amp;nbsp; private UriInfo uriInfo;

&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override
&amp;nbsp;&amp;nbsp;&amp;nbsp; public List&lt;resourcefilter&gt; create(AbstractMethod method) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return Collections.singletonList((ResourceFilter) new Filter());
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; private class Filter implements ResourceFilter, ContainerRequestFilter {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; protected Filter() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public ContainerRequestFilter getRequestFilter() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return this;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public ContainerResponseFilter getResponseFilter() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return null;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public ContainerRequest filter(ContainerRequest request) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; logger.info("Url invoked is {}", uriInfo.getPath());
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String authHeader = request.getHeaderValue("Authorization");
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (authHeader != null &amp;amp;&amp;amp; authHeader.startsWith("Basic ")) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; User user = BasicAuthHelper.authenticateUser(request);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; if (user == null) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new WebApplicationException(Response.Status.UNAUTHORIZED);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return request;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new WebApplicationException(Response.Status.UNAUTHORIZED);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}

&lt;/resourcefilter&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-983802465891407658?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hezD9NMez7rHxHSF0xTBqaUfmkU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hezD9NMez7rHxHSF0xTBqaUfmkU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hezD9NMez7rHxHSF0xTBqaUfmkU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hezD9NMez7rHxHSF0xTBqaUfmkU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/uIt87p2saVU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/983802465891407658/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/11/jesey-writing-authentication-filter.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/983802465891407658?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/983802465891407658?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/uIt87p2saVU/jesey-writing-authentication-filter.html" title="Jesey writing an authentication filter" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>3</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/11/jesey-writing-authentication-filter.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8ARXw-cCp7ImA9WhRTEE4.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-8736264677480711296</id><published>2011-10-30T23:00:00.000-05:00</published><updated>2011-10-30T23:04:04.258-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-30T23:04:04.258-05:00</app:edited><title>Jersey Rest API html documentation</title><content type="html">There are various ways to generate REST api documentation but how can you do it with minimal effort. Unless you are looking into very sophisticated documentation like twitter https://dev.twitter.com/docs/api,  the below should suffice. If you though however want to generate twitter like documentation then also 70% of what I highlighted would work.&lt;br /&gt;
&lt;br /&gt;
Jersey by default supports WADL generation by default. &lt;a href="http://en.wikipedia.org/wiki/Web_Application_Description_Language"&gt;WADL&lt;/a&gt; is machine readable rest api description simliar to what WDSL was to soap.  In order to get to default wadl generated by jersey you can just call http://localhost:8080/application.wadl . This WADL is a XML document so all you need now is to render it with a stylesheet. WADL has documentation tags that can be used to document a resource byt unfortunately jersey by default doesnt generate documentation tags.&lt;br /&gt;
&lt;br /&gt;
So to get real html documentation the steps are:&lt;br /&gt;
1) &lt;b&gt;Document you rest services using Java docs&lt;/b&gt; for the resource class and resource method. The down side of using java docs is that you will have to write the params in the method instead of declaring them as instance vars but its much better as you can kill two birds in one shot. You get javadocs for internal devloper and html documentation for rest api consumers.
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;@Path("/user")
public class UserRestService extends SecureRestService {
 /**
  * Gets user by userName.
  *  
  * An example of the output json is 
  *  
  *  {"prefix":"kpatel",
  *  "userNum":11,
  *  "firstName":"Kalpesh",
  *  "lastName":"Patel",
  *  "emailAddress":"kpatel@gmail.com"}
  *
  * @param userName UserName that is to be fetched. 
  * @response.representation.200.mediaType application/json
  * @response.representation.200.example  
  * @return the user json object
  * @throws IOException
  */
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 @Path("username/{username}")
 public String getUser(@PathParam("username") String userName) throws IOException {
  ....
 }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
2) &lt;b&gt;Extract Javadocs to a resource-doc file&lt;/b&gt; to be used by jersey wadl generator.&amp;nbsp; We would use a ant task to generate this file and place it in a path that can be read from the classpath by the running application.&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;target name="check-resourcedoc-exists"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;available file="${basedir}/build/jersey-doc-dep/resourcedoc.xml" property="jersey.resourcedoc.present"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/target&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;target name="setup-jersey-wadl-dependencies" depends="check-resourcedoc-exists" unless="jersey.resourcedoc.present"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;delete dir="build/jersey-doc-dep" /&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mkdir dir="build/jersey-doc-dep" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;javadoc access="public" classpathref="compile.classpath"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fileset dir="modules/server/src/java" defaultexcludes="yes"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;include name="**/*.java" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/fileset&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fileset dir="modules/server/build/gen-src/java" defaultexcludes="yes"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;include name="**/*.java" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/fileset&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fileset dir="modules/ui/src/java" defaultexcludes="yes"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;include name="**/*.java" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/fileset&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;doclet name="com.sun.jersey.wadl.resourcedoc.ResourceDoclet" pathref="compile.classpath"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;param name="-output" value="${basedir}/build/jersey-doc-dep/resourcedoc.xml" /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/doclet&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/javadoc&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;copy todir="${war.path}/WEB-INF/classes"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fileset dir="modules/server/resource/jersey-doc-dep"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;include name="*.xml"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/fileset&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fileset dir="build/jersey-doc-dep"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;include name="*.xml"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/fileset&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/copy&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/target&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
3) &lt;b&gt;Add static documentation for the whole app&lt;/b&gt; and any a grammar file. This has to be hand written. I won't desrcibe the grammar file in details but it can be used for jaxb examples using some custom jersey example tags .&lt;br /&gt;
This is the application-doc.xml file&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;lt;applicationDocs targetNamespace="http://wadl.dev.java.net/2009/02"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;doc xml:lang="en" title="The doc for My app API"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; My app documentation. You need to fill this in.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/doc&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/applicationDocs&amp;gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
This is the application-grammars.xml file&lt;br /&gt;
&lt;code&gt; &lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;lt;grammars xmlns="http://wadl.dev.java.net/2009/02"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:xsd="http://www.w3.org/2001/XMLSchema"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:xi="http://www.w3.org/1999/XML/xinclude"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;include href="schema.xsd" /&amp;gt;&lt;br /&gt;&amp;lt;/grammars&amp;gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
4) &lt;b&gt;Configure jersey WADL generator&lt;/b&gt; to read resourcedoc.xml file and generate documentation tags in the wadl.&lt;br /&gt;
&lt;br /&gt;
Add an init-param to your jersey filter&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;init-param&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;param-name&amp;gt;com.sun.jersey.config.property.WadlGeneratorConfig&amp;lt;/param-name&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;param-value&amp;gt;com.foo.bar.MyWadlGeneratorConfig&amp;lt;/param-value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/init-param&amp;gt; &lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Add this class&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
public class MyWadlGeneratorConfig extends WadlGeneratorConfig {
&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override
&amp;nbsp;&amp;nbsp;&amp;nbsp; public List&lt;wadlgeneratordescription&gt; configure() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return generator(MyWadlGenerator.class).generator(WadlGeneratorApplicationDoc.class).prop(
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; "applicationDocsFile", "classpath:/application-doc.xml")
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .generator(WadlGeneratorGrammarsSupport.class).prop(
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; "grammarsFile", "classpath:/application-grammars.xml")
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .generator(WadlGeneratorResourceDocSupport.class).prop(
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; "resourceDocFile", "classpath:/resourcedoc.xml")
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .descriptions();
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

}&lt;/wadlgeneratordescription&gt;

&lt;/code&gt;&lt;/pre&gt;
5) &lt;b&gt;Inject html generating stylesheet&lt;/b&gt;. You can use the two stylesheet&lt;br /&gt;
https://github.com/mnot/wadl_stylesheets/ or https://github.com/ipcsystems/wadl-stylesheet&lt;br /&gt;
&lt;br /&gt;
I prefered the ipc one as I didnt had initial documentation for each method and this one looked more better.&lt;br /&gt;
&lt;br /&gt;
Doing this was the one thing took most of the time. At the end I ended up writing my own WadlResource.&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
@Produces( { "application/vnd.sun.wadl+xml", "application/xml"})
@Singleton
@Path("application.wadl")
public final class WadlResource {

 private static final AppLogger logger = AppLogger
   .getLogger(WadlResource.class);

 private WadlApplicationContext wadlContext;

 private Application application;

 private byte[] wadlXmlRepresentation;

 public WadlResource(@Context WadlApplicationContext wadlContext) {
  this.wadlContext = wadlContext;
 }

 @GET
 public synchronized Response getWadl(@Context UriInfo uriInfo) {
  if (wadlXmlRepresentation == null) {
   String styleSheetUrl = uriInfo.getBaseUri().toString() + "wadl.xsl";
   this.application = wadlContext.getApplication(uriInfo).getApplication();
   try {
    Marshaller marshaller = wadlContext.getJAXBContext()
      .createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
                Writer writer = new OutputStreamWriter(os);
                writer.write("\n");
                writer.write("\n");
                marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
    marshaller.marshal(application, writer);
    writer.flush();
    writer.close();
    wadlXmlRepresentation = os.toByteArray();
    os.close();
   } catch (Exception e) {
    logger.error("Could not marshal wadl Application.", e);
    return Response.ok(application).build();
   }
  }

  return Response.ok(new ByteArrayInputStream(wadlXmlRepresentation))
    .build();
 }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;If you want twitter like documentation where you want to categorise resource&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;and other stuff then all you need now is to skip step 5 and add an ant task&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;to generate wadl with docs and feed it to a python program that can generate&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;the html doc at build time.&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-8736264677480711296?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Fuy7M5V_5sAeE9-Zwb6WcU0q0Fw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Fuy7M5V_5sAeE9-Zwb6WcU0q0Fw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Fuy7M5V_5sAeE9-Zwb6WcU0q0Fw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Fuy7M5V_5sAeE9-Zwb6WcU0q0Fw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/ow7suZ3T73w" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/8736264677480711296/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/10/jersey-rest-api-html-documentation.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/8736264677480711296?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/8736264677480711296?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/ow7suZ3T73w/jersey-rest-api-html-documentation.html" title="Jersey Rest API html documentation" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/10/jersey-rest-api-html-documentation.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUANRH85eip7ImA9WhdbF0w.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-2175586928860958651</id><published>2011-10-15T17:23:00.000-05:00</published><updated>2011-10-15T17:29:55.122-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-15T17:29:55.122-05:00</app:edited><title>Generating pdf out of html using Java</title><content type="html">I had this requirement of generating PDF out of HTML content. Users can add any kind of html content on a Rich text editor from few lines to a full paragraph as notes for a file and save it on the server. Now I had to notify other users when some user adds a note. Now in the past I have generated PDF for reports but that was on a structured data straight out of database so I could easily use something like itext or jasperreports but&amp;nbsp; this one seems an interesting problem as user can do any free form html in the editor.&lt;br /&gt;
&lt;br /&gt;
Ultimately the solution came to be:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Convert the html added by user into xhtml using JTidy&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Use flying saucer's ITextRenderer (&lt;a href="http://code.google.com/p/flying-saucer/"&gt;http://code.google.com/p/flying-saucer/&lt;/a&gt;) to generate the pdf out of xhtml.&lt;/li&gt;
&lt;/ol&gt;
Here is a sample code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
public class TextSectionConverter {

 private String notesContent;

 public TextSectionConverter(String notesContent) {
  this.notesContent = notesContent;
 }

 public void writeAsPdf(FileOutputStream fos)
   throws Exception {
  convertToXHTML();
  ITextRenderer renderer = new ITextRenderer();
  renderer.setDocumentFromString(notesContent);
  renderer.layout();
  renderer.createPDF(fos);
 }

 void convertToXHTML() throws Exception {
  notesContent = "" + notesContent + "";
  StringWriter writer = new StringWriter();
  Tidy tidy = new Tidy();
  tidy.setTidyMark(false);
  tidy.setDocType("omit");
  tidy.setXHTML(true);
  tidy.setInputEncoding("utf-8");
  tidy.setOutputEncoding("utf-8");
  tidy.parse(new StringReader(notesContent), writer);
  writer.close();
  notesContent = writer.toString();
 }
&lt;/code&gt;
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-2175586928860958651?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MA1b3MazSSec2l6oGu5jCKdCdBU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MA1b3MazSSec2l6oGu5jCKdCdBU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MA1b3MazSSec2l6oGu5jCKdCdBU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MA1b3MazSSec2l6oGu5jCKdCdBU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/a4NCWu1IviM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/2175586928860958651/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/10/generating-pdf-out-of-html.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/2175586928860958651?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/2175586928860958651?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/a4NCWu1IviM/generating-pdf-out-of-html.html" title="Generating pdf out of html using Java" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/10/generating-pdf-out-of-html.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkAMQXg6fyp7ImA9WhdWFks.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-940135098172557284</id><published>2011-09-10T01:30:00.001-05:00</published><updated>2011-09-10T10:33:00.617-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-10T10:33:00.617-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="cloud" /><title>biggest concern with moving your applications to the cloud?</title><content type="html">wow I wrote about enterprise cloud adoption and found this poll on my linkedin profile that validates my thinking of security and reliability being biggest concerns for cloud adoption by enterpries.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-V4RPlUTiJUc/TmsEWgFCvAI/AAAAAAAAB5I/YwIWSOQUa_Q/s1600/Screenshot-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="281" src="http://1.bp.blogspot.com/-V4RPlUTiJUc/TmsEWgFCvAI/AAAAAAAAB5I/YwIWSOQUa_Q/s400/Screenshot-1.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-940135098172557284?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/r6OejWJFlVnQVkGgMAHURlEJPtY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/r6OejWJFlVnQVkGgMAHURlEJPtY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/r6OejWJFlVnQVkGgMAHURlEJPtY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/r6OejWJFlVnQVkGgMAHURlEJPtY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/_1a9MChd3AU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/940135098172557284/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/09/biggest-concern-with-moving-your.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/940135098172557284?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/940135098172557284?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/_1a9MChd3AU/biggest-concern-with-moving-your.html" title="biggest concern with moving your applications to the cloud?" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-V4RPlUTiJUc/TmsEWgFCvAI/AAAAAAAAB5I/YwIWSOQUa_Q/s72-c/Screenshot-1.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/09/biggest-concern-with-moving-your.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkAESH0_eyp7ImA9WhdWFks.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-5641416506025535360</id><published>2011-09-09T22:42:00.001-05:00</published><updated>2011-09-10T10:31:49.343-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-10T10:31:49.343-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="cloud" /><title>Enterprise customers and Cloud Adoption</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
A big fear among enterprise customers who want to adopt cloud is that&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Is my data secure?&lt;/li&gt;
&lt;li&gt;What if this site goes down for 3-4 hours?&lt;/li&gt;
&lt;li&gt;What if this startup shutdown business, what will happen to my data?&lt;/li&gt;
&lt;/ol&gt;
Recent downtimes from big companies as shown below instills a fear among mission critical busineses wanting to adopt cloud. &lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt; Microsoft &lt;a href="http://techcrunch.com/2011/09/09/microsofts-cloud-briefly-evaporates-leaves-up-to-365-million-users-without-access-for-four-hours/"&gt;http://techcrunch.com/2011/09/09/microsofts-cloud-briefly-evaporates-leaves-up-to-365-million-users-without-access-for-four-hours/&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Amazon &lt;a href="http://eu.techcrunch.com/2011/04/21/amazon-ec2-goes-down-taking-with-it-reddit-foursquare-and-quora/"&gt;http://eu.techcrunch.com/2011/04/21/amazon-ec2-goes-down-taking-with-it-reddit-foursquare-and-quora/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Google App Engine &lt;a href="http://techcrunch.com/2011/09/09/google-explains-its-google-docs-outage/"&gt;http://techcrunch.com/2011/09/09/google-explains-its-google-docs-outage/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
While moving to cloud makes sense economically but having one bad day can make people go back to traditional methods of manging own infrastructure. Think of a hospital storing all records in cloud, it cant afford a 2-3 hour downtime. There is a better solution to this and its by adopting the hybrid model and companies that will do it successfully will see far more growth in enterprise area. The idea is to have an on-premise cloud that syncs to the real cloud. This way even if the real cloud is down or goes out of business, the on-premise instance ensures business continuity.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-5641416506025535360?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/dgGdGsZRVJbn1E0NDXS6qlEH2mw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dgGdGsZRVJbn1E0NDXS6qlEH2mw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/dgGdGsZRVJbn1E0NDXS6qlEH2mw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dgGdGsZRVJbn1E0NDXS6qlEH2mw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/knSdyV5o4Pc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/5641416506025535360/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/09/enterprise-customers-and-cloud-adoption.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/5641416506025535360?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/5641416506025535360?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/knSdyV5o4Pc/enterprise-customers-and-cloud-adoption.html" title="Enterprise customers and Cloud Adoption" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/09/enterprise-customers-and-cloud-adoption.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkEMSHk5eip7ImA9WhdWFks.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-186697674960070460</id><published>2011-09-09T22:32:00.000-05:00</published><updated>2011-09-10T10:31:29.722-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-10T10:31:29.722-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="performance" /><category scheme="http://www.blogger.com/atom/ns#" term="junit" /><title>Making Junit tests faster</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I had some batch of Junit tests that were taking close to 20 minutes and it was wasteful to wait everytime before checking in code, one trick I found was to use the forkmod="once" property. Using this reduce the time to 5 minute 8 sec. &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;junit tempdir="build" printsummary="on" fork="yes" &lt;b&gt;forkmode="once" &lt;/b&gt;haltonfailure="${test.haltonfailure}" failureproperty="tests.failed" showoutput="false"&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Earlier Junit was forking a JVM per test and now its doing one for all test so its very fast. Here is some documentation from Junit on this property.&lt;br /&gt;
&lt;div style="color: #0c343d;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="color: purple;"&gt;
Controls how many Java Virtual Machines get
    created if you want to fork some tests.  Possible values are
    "perTest" (the default), "perBatch" and
    "once".  "once" creates only a single Java VM
    for all tests while "perTest" creates a new VM for each
    TestCase class.  "perBatch" creates a VM for each nested
    &lt;code&gt;&lt;batchtest&gt;&lt;/batchtest&gt;&lt;/code&gt; and one collecting all nested
    &lt;code&gt;&lt;test&gt;&lt;/test&gt;&lt;/code&gt;s.  Note that only tests with the same
    settings of &lt;code&gt;filtertrace&lt;/code&gt;, &lt;code&gt;haltonerror&lt;/code&gt;,
    &lt;code&gt;haltonfailure&lt;/code&gt;, &lt;code&gt;errorproperty&lt;/code&gt; and
    &lt;code&gt;failureproperty&lt;/code&gt; can share a VM, so even if you set
    &lt;code&gt;forkmode&lt;/code&gt; to "once", Ant may have to create
    more than a single Java VM.  This attribute is ignored for tests
    that don't get forked into a new Java VM.  &lt;i&gt;since Ant 1.6.2&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-186697674960070460?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/yKF9Uywl7ifBlL7f4cysTKp3ZDA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yKF9Uywl7ifBlL7f4cysTKp3ZDA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/yKF9Uywl7ifBlL7f4cysTKp3ZDA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yKF9Uywl7ifBlL7f4cysTKp3ZDA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/YePv9L560L4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/186697674960070460/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/09/making-junit-tests-faster.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/186697674960070460?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/186697674960070460?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/YePv9L560L4/making-junit-tests-faster.html" title="Making Junit tests faster" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/09/making-junit-tests-faster.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkEFQHk_eSp7ImA9WhdWFks.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-2078785581427045296</id><published>2011-09-09T22:25:00.001-05:00</published><updated>2011-09-10T10:30:11.741-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-10T10:30:11.741-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="selenium" /><category scheme="http://www.blogger.com/atom/ns#" term="ExtJS" /><title>Selenium and ExtJS</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
A trick to test selenium with ExtJS is to use cssSelectors. As an element can have more than one css classes and you really dont need to define any style for that css class it can be a good locator for the element and faster than XPATH on IE.&lt;br /&gt;
&lt;br /&gt;
You can define cssSelector as&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tbar: {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; xtype: 'toolbar',&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; items: [&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; xtype: 'button',&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; text: 'Send',&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cls: 'x-btn-text',&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; overCls: 'x-btn-noicon',&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ctCls: 't-btn-yellow x-btn-over',&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; iconCls: 't-send &lt;b&gt;seleniumSendNote&lt;/b&gt;',&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...........&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...........&lt;br /&gt;
and you can then in your test call the button click as&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driver.findElement(By.cssSelector("button.seleniumSendNote"))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .click();&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-2078785581427045296?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/KMBmPSmlmnG2Orz07UGwOBgDvis/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KMBmPSmlmnG2Orz07UGwOBgDvis/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/KMBmPSmlmnG2Orz07UGwOBgDvis/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KMBmPSmlmnG2Orz07UGwOBgDvis/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/13J-TGbMOT0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/2078785581427045296/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/09/selenium-and-extjs.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/2078785581427045296?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/2078785581427045296?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/13J-TGbMOT0/selenium-and-extjs.html" title="Selenium and ExtJS" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/09/selenium-and-extjs.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkEARH0zfip7ImA9WhdWFks.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-3744819044671167272</id><published>2011-09-09T22:19:00.003-05:00</published><updated>2011-09-10T10:30:45.386-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-10T10:30:45.386-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="selenium" /><category scheme="http://www.blogger.com/atom/ns#" term="htmleditor" /><category scheme="http://www.blogger.com/atom/ns#" term="ExtJS" /><title>Selenium and ExtJS HtmlEditor</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I had to add a selenium test for a page with ExtJS HtmlEditor and selenium wont recognize it, even tests recorded with Selenium IDE wont recognize it. The reason is that HtmlEditor uses a hidden textarea and a DIV on top of it to trap keystrokes. I tried using lots of ways to set text into it but it would complain about component not visible&amp;nbsp; and other stuff. Finally the only way I could do is to execute Javascript from webdriver. Here is the code that I used to set the text.&lt;/div&gt;
&lt;pre&gt;&lt;code&gt;
                String notes = "This is a test note from selenium";
		JavascriptExecutor js = (JavascriptExecutor) driver;
		js.executeScript("Ext.getCmp('notes').setValue('"
				+ notes + "')");
&lt;/code&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-3744819044671167272?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/W2rrH7ubBXnlfN2aCmPnU29orlA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W2rrH7ubBXnlfN2aCmPnU29orlA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/W2rrH7ubBXnlfN2aCmPnU29orlA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W2rrH7ubBXnlfN2aCmPnU29orlA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/sU9LfKQWWmI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/3744819044671167272/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/09/selenium-and-extjs-htmleditor.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/3744819044671167272?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/3744819044671167272?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/sU9LfKQWWmI/selenium-and-extjs-htmleditor.html" title="Selenium and ExtJS HtmlEditor" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/09/selenium-and-extjs-htmleditor.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUAHQHoyeCp7ImA9WhdbF0w.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-8820767442515380691</id><published>2011-08-29T16:38:00.000-05:00</published><updated>2011-10-15T17:28:51.490-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-15T17:28:51.490-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="lsof" /><title>Java and lsof</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Update&lt;/b&gt;: I found that using Runtime.exec was a bad idea because if you have a 2GB VM footprint then the forked process would require 2G free memory in order to run the lsof command.&amp;nbsp; We had earlier writte a simple python http rpc server that would allow us to execute native commands(like creating a hardlink or running gunzip) from Java and I changed this code to delagate to RPC call few days back.&lt;br /&gt;
So the new code looks like&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
&lt;code&gt;

 public void writeTopCommandOutput(Writer writer) throws IOException {
  String rpcRes = Util.doCommandRpc(rpcUrl, "", ListUtil.create("top", "-n", "2", "-b", "-d", "0.2"));
  writer.write(rpcRes);
 }

 public void writeLsofOutput(Writer writer) throws IOException {
  String pid = getJvmProcessid();
  if (pid != null) {
   pid = pid.trim();
   String rpcRes = Util.doCommandRpc(rpcUrl, "", ListUtil.create("lsof", "-p", pid));
   writer.write(rpcRes);
  }
 }
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
&amp;nbsp;--------------------------------------&lt;br /&gt;
I was chasing a customer issue and some threads in threaddump showed that they are stuck doing filer I/O. Now I needed to chase what file paths these threads are accessing as few days ago this customer had expereinced same issue. So I asked operations to give me lsof output and as we are a distribured team and engineers dont have access to production machines.It always takes time to chase people and to a programmer this means lots of context switches and it derails your thought process.&amp;nbsp; My goal is to eliminate as many hoops in my debugging path so I wrote a JSP to get me lsof output from java. This will be a jsp accessible through internal ips only, hurray from next release onwards one more reason to avoid Operations team in chasing issues.&lt;br /&gt;
Here is the method I added in jsp&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void writeLsofOutput(Writer writer) throws IOException {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String pid = getJvmProcessid();
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(pid!=null){
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; pid = pid.trim();
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String cmdLsof = "lsof -p " + pid;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; executeCmd(writer, cmdLsof);&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; private void executeCmd(Writer writer, String cmd) throws IOException {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String output;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Process child = Runtime.getRuntime().exec(cmd, new String []{});&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; while ((output = stdInput.readLine()) != null) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writer.write(output + "\n");
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writer.flush();
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; stdInput.close();
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; public String getJvmProcessid() throws IOException {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String pid = null;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; File pidFile = new File(System.getenv("CATALINA_PID"));
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(pidFile.exists()) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; FileInputStream fin = new FileInputStream(pidFile);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; List&lt;string&gt; lines = IOUtils.readLines(fin);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; fin.close();
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; pid = StringUtils.join(lines.toArray());
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return pid;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/string&gt;&lt;/code&gt;
&lt;/pre&gt;
&lt;code&gt;&lt;br /&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-8820767442515380691?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/PHVWZvpSexcCk_x2ODIUxJ063Os/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PHVWZvpSexcCk_x2ODIUxJ063Os/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/PHVWZvpSexcCk_x2ODIUxJ063Os/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PHVWZvpSexcCk_x2ODIUxJ063Os/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/6OvP2R2upwQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/8820767442515380691/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/08/java-and-lsof.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/8820767442515380691?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/8820767442515380691?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/6OvP2R2upwQ/java-and-lsof.html" title="Java and lsof" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/08/java-and-lsof.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEUCRXc4eip7ImA9WhdQEkw.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-2820045389437152057</id><published>2011-08-13T00:11:00.000-05:00</published><updated>2011-08-13T00:11:04.932-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-13T00:11:04.932-05:00</app:edited><title>Programatically extracting quoted reply from an email</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;When files are uploaded to our cloud file server, we wanted to send notification email per file with its own unique email address. I will discuss how to have so many unique email address without creating a user on mail server for each file and scale out the solution in some later blog. People can just hit reply button on the generated notification email and comment on the uploaded file. When reply email reaches back the server we want to extract the comment that user added after stripping out the quoted reply form the mail client and add the clean comment to file. Seems like an easy problem isnt it, but unfortunately there is no easy way to detect the quoted reply from an incoming email because different mail clients use different way to quote a reply. On top of it quoted reply of html emails are different than plain text quoted replies.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Angle Brackets "&amp;gt; xxx zzz" &lt;/li&gt;
&lt;li&gt;"---Original Message---"&lt;/li&gt;
&lt;li&gt;"On such-and-such day, so-and-so wrote:"&lt;/li&gt;
&lt;li&gt;html email reply in thunderbird uses blockquote tags.&lt;/li&gt;
&lt;li&gt; yahoo/hotmail uses some div tags&lt;/li&gt;
&lt;/ol&gt;Got an brilliant idea from someone to add a hash marker in the outbound notification email&amp;nbsp; so that when it comes back we can strip the text after that marker. Then I found other sites are already doing this like redmine or issueburner already does that. These guys add a marker text in outbound email like below&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style="font-size: xx-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;##### Please do not write below this line #####&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Hi kalpesh,&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;The issue has been updated.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Updated by: &amp;nbsp;&amp;nbsp;&amp;nbsp; Kris Katta&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Comment added: &amp;nbsp;&amp;nbsp;&amp;nbsp; this is a test comment&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;/span&gt;&lt;span style="font-size: xx-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Kris Katta's Reply..&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;This is a test reply&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;To track the status of your request and set up a profile for yourself, follow the link below:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now all that is left to extract the mail header so using some regex you can strip that. I&amp;nbsp; have handled thunderbird and outlook and will soon add yahoo/hotmail. Below is some sample code.&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;/**
&amp;nbsp;* @author kpatel
&amp;nbsp;*/
public class QuotedReplyExtractor {
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static final String&amp;nbsp;&lt;/code&gt;
&lt;code&gt;REPLY_MARKER = "--- Please reply ABOVE THIS LINE to comment on this file ---";

&amp;nbsp;&amp;nbsp;&amp;nbsp; private static final List&lt;pattern&gt; patterns = new ArrayList&lt;pattern&gt;();
&amp;nbsp;&amp;nbsp;&amp;nbsp; static {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; patterns
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .add(Pattern.compile(".*on.*?wrote:", Pattern.CASE_INSENSITIVE));
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; patterns.add(Pattern.compile("-+original\\s+message-+\\s*",
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Pattern.CASE_INSENSITIVE));
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; public String stripQuotedReply(String comment) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int startIndex = comment.indexOf(REPLY_MARKER);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (startIndex &amp;gt; 0) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; comment = comment.substring(0, startIndex);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for (Pattern pattern : patterns) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Matcher matcher = pattern.matcher(comment);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (matcher.find()) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; startIndex = matcher.start();
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; comment = comment.substring(0, startIndex);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return comment;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

} &lt;/pattern&gt;&lt;/pattern&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;code&gt;&lt;br /&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-2820045389437152057?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/khLB974uwdtOFa-gbgDQpzjuvx4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/khLB974uwdtOFa-gbgDQpzjuvx4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/khLB974uwdtOFa-gbgDQpzjuvx4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/khLB974uwdtOFa-gbgDQpzjuvx4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/AN-B3fQgMqQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/2820045389437152057/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/08/programatically-extracting-quoted-reply.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/2820045389437152057?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/2820045389437152057?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/AN-B3fQgMqQ/programatically-extracting-quoted-reply.html" title="Programatically extracting quoted reply from an email" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/08/programatically-extracting-quoted-reply.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQARn48eCp7ImA9WhdQEE4.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-939887635624946110</id><published>2011-08-10T22:29:00.000-05:00</published><updated>2011-08-10T22:29:07.070-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-10T22:29:07.070-05:00</app:edited><title>Spring MVC and Unicode characters</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;We ran into an issue where some user tried entering Danish character ø in his first name and it was not updating properly in LDAP. First we thought its a LDAP issue but then I found that in some other page where we use DWR api the same character is getting updated in LDAP properly. Finally we nailed it down to Tomcat/Spring where even after doing&lt;br /&gt;
&lt;pre id="line1"&gt;&amp;lt;&lt;span class="start-tag"&gt;meta&lt;/span&gt;&lt;span class="attribute-name"&gt; http-equiv&lt;/span&gt;=&lt;span class="attribute-value"&gt;"Content-Type" &lt;/span&gt;&lt;span class="attribute-name"&gt;content&lt;/span&gt;=&lt;span class="attribute-value"&gt;"text/html; charset=UTF-8" &lt;/span&gt;&lt;span class="error"&gt;&lt;span class="attribute-name"&gt;/&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre id="line1"&gt;the character encoding was not properly set on request.&lt;/pre&gt;&lt;pre id="line1"&gt;&lt;/pre&gt;&lt;pre id="line1"&gt;Adding this filter solved the issue. This has to be first filter in web.xml,&lt;/pre&gt;&lt;pre id="line1"&gt;otherwise it wont work, I had it earlier as the second filter and i wasted some time debugging it&lt;/pre&gt;&lt;pre id="line1"&gt;	 &amp;lt;filter&amp;gt;
		&amp;lt;!-- Filter to handle content encoding for UTF-8 encoding, this has to be the FIRST FILTER, do not move --&amp;gt;
	    &amp;lt;filter-name&amp;gt;encodingFilter&amp;lt;/filter-name&amp;gt;&lt;/pre&gt;&lt;pre id="line1"&gt;&amp;lt;filter-class&amp;gt;org.springframework.web.filter.CharacterEncodingFilter&amp;lt;/filter-class&amp;gt;
	    &amp;lt;init-param&amp;gt;
	        &amp;lt;param-name&amp;gt;encoding&amp;lt;/param-name&amp;gt;
	        &amp;lt;param-value&amp;gt;UTF-8&amp;lt;/param-value&amp;gt;
	    &amp;lt;/init-param&amp;gt;
	    &amp;lt;init-param&amp;gt;
	        &amp;lt;param-name&amp;gt;forceEncoding&amp;lt;/param-name&amp;gt;
	        &amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;
	    &amp;lt;/init-param&amp;gt;
	 &amp;lt;/filter&amp;gt;
	 &amp;lt;filter-mapping&amp;gt;
	    &amp;lt;filter-name&amp;gt;encodingFilter&amp;lt;/filter-name&amp;gt;
	    &amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt;
	 &amp;lt;/filter-mapping&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;pre id="line1"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre id="line1"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre id="line1"&gt;Technically all its doing is&amp;nbsp;&lt;/pre&gt;&lt;pre id="line1"&gt;request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");&amp;nbsp;&lt;/pre&gt;&lt;pre id="line1"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre id="line1"&gt;Ideally this should be set by tomcat as I had the below set,&lt;/pre&gt;&lt;pre id="line1"&gt;but its not working somehow so setting this filter made it work.&amp;nbsp;&lt;/pre&gt;&lt;pre id="line1"&gt;DWR was parsing the request body manually and thats why it was working and spring was not. &lt;/pre&gt;&lt;pre id="line1"&gt;&amp;lt;Connector port="8080" URIEncoding="UTF-8" ......&amp;gt;&lt;/pre&gt;&lt;pre id="line1"&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-939887635624946110?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/7VP2Ij94wXadk9UTisWVw1USM4I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7VP2Ij94wXadk9UTisWVw1USM4I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/7VP2Ij94wXadk9UTisWVw1USM4I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7VP2Ij94wXadk9UTisWVw1USM4I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/VEd6pU95RzU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/939887635624946110/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/08/spring-mvc-and-unicode-characters.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/939887635624946110?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/939887635624946110?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/VEd6pU95RzU/spring-mvc-and-unicode-characters.html" title="Spring MVC and Unicode characters" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/08/spring-mvc-and-unicode-characters.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEYCRnk7fyp7ImA9WhdQEE4.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-3248838550923293727</id><published>2011-08-10T22:09:00.000-05:00</published><updated>2011-08-10T22:09:27.707-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-10T22:09:27.707-05:00</app:edited><title>mysql execute immediate</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;I had a requirement to generate a sharded schema where no of shards and no of tables in the shard were dynamic. Basically we wanted to shard one table so we ended up creating 8 schemas and each schema will hold 8 tables that are copy of the same schema. Now I didnt wanted to hand write the 64 table/schema creation statement so came up with this procedure that allows to dynamically build and execute sql queries.&amp;nbsp; Oracle was so easy, mysql is a little bit verbose.&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop procedure if exists create_rdb_tables;
&amp;nbsp;&amp;nbsp;&amp;nbsp; delimiter #
&amp;nbsp;&amp;nbsp;&amp;nbsp; create procedure create_rdb_tables()
&amp;nbsp;&amp;nbsp;&amp;nbsp; begin
&amp;nbsp;&amp;nbsp;&amp;nbsp; declare v_max int unsigned default 9;
&amp;nbsp;&amp;nbsp;&amp;nbsp; declare v_counteri int unsigned default 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; declare v_counterj int unsigned default 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; while v_counteri &amp;lt; v_max do
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; while v_counterj &amp;lt; v_max do
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @sql_text := concat('drop table if exists metadata_rdb_schema',v_counteri, '.metadata_rdb_t', v_counterj,';');
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prepare stmt from @sql_text;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; execute stmt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEALLOCATE PREPARE stmt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @sql_text := concat('CREATE TABLE metadata_rdb_schema',v_counteri, '.metadata_rdb_t', v_counterj, ' (user_id INT NOT NULL, object_id VARCHAR(255) NOT NULL,group_id VARCHAR(36) NOT NULL,entry_id VARCHAR(36) NOT NULL,created_time DATETIME NOT NULL, primary key(object_id))TYPE=innodb;');
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prepare stmt from @sql_text;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; execute stmt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEALLOCATE PREPARE stmt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set v_counterj=v_counterj+1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; end while;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; set v_counteri=v_counteri+1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; end while;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end #
&amp;nbsp;&amp;nbsp;&amp;nbsp; delimiter ;
&amp;nbsp;&amp;nbsp;&amp;nbsp; call create_rdb_tables();
&amp;nbsp;&amp;nbsp;&amp;nbsp; drop procedure if exists create_rdb_tables; &lt;/code&gt;
&lt;/pre&gt;&lt;code&gt;&lt;br /&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt; &lt;br /&gt;
&lt;br /&gt;
Finally it started becoming messy and kludgy so I ended up writing clean python code to generate the ddl :). This effort was a waste but I ended up learning how to do dynamic sql execution in mysql.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-3248838550923293727?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/TNXdhq7xWRIUy256e5ondi9IR5c/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TNXdhq7xWRIUy256e5ondi9IR5c/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/TNXdhq7xWRIUy256e5ondi9IR5c/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TNXdhq7xWRIUy256e5ondi9IR5c/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/8K8tJG3WV_c" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/3248838550923293727/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/08/mysql-execute-immediate.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/3248838550923293727?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/3248838550923293727?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/8K8tJG3WV_c/mysql-execute-immediate.html" title="mysql execute immediate" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/08/mysql-execute-immediate.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkEMSH04eyp7ImA9WhdRGU8.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-3805512578098801006</id><published>2011-08-09T15:11:00.000-05:00</published><updated>2011-08-09T15:11:29.333-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-09T15:11:29.333-05:00</app:edited><title>ProcessId 911</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-jBXun5mG4KI/TkGUN64MdII/AAAAAAAAB48/oPsUjVRCy2A/s1600/processId_911.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="108" src="http://3.bp.blogspot.com/-jBXun5mG4KI/TkGUN64MdII/AAAAAAAAB48/oPsUjVRCy2A/s400/processId_911.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
call it good luck I got process id 911 for java. :).&amp;nbsp; Hiding my laptop name to keep it anonymous. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-3805512578098801006?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/PsiSmoiXXr4BVY8XjCc-AoVvkpU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PsiSmoiXXr4BVY8XjCc-AoVvkpU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/PsiSmoiXXr4BVY8XjCc-AoVvkpU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PsiSmoiXXr4BVY8XjCc-AoVvkpU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/uLTACEzsKjs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/3805512578098801006/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/08/processid-911.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/3805512578098801006?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/3805512578098801006?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/uLTACEzsKjs/processid-911.html" title="ProcessId 911" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-jBXun5mG4KI/TkGUN64MdII/AAAAAAAAB48/oPsUjVRCy2A/s72-c/processId_911.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/08/processid-911.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4FQXc4cCp7ImA9WhdRE0k.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-80746193501159241</id><published>2011-08-02T22:41:00.000-05:00</published><updated>2011-08-02T22:41:50.938-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-02T22:41:50.938-05:00</app:edited><title>Tomcat configurable session timeout per customer</title><content type="html">We are a cloud file provider and more geared towards enterprise customers. We have a default session timeout of 6 hours for web ui access and recently customers had a requirement that they wanted to configure a session timeout themselves. As we host multiple customers on one node, this was an interesting requirement and we were discussing all sorts of hacks until I landed on to this api &lt;a href="http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpSession.html#setMaxInactiveInterval%28int%29"&gt;HttpSession.setMaxInactiveInterval&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
So now all we need to do is upon successful login, check if admin has overridden session timeout settings for this enterprise and set that on session using the above api.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-80746193501159241?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/UpcDKyLGwdlzEOeyQtN0CdlHCgs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/UpcDKyLGwdlzEOeyQtN0CdlHCgs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/UpcDKyLGwdlzEOeyQtN0CdlHCgs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/UpcDKyLGwdlzEOeyQtN0CdlHCgs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/2oPNaUcHABw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/80746193501159241/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/08/tomcat-configurable-session-timeout-per.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/80746193501159241?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/80746193501159241?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/2oPNaUcHABw/tomcat-configurable-session-timeout-per.html" title="Tomcat configurable session timeout per customer" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/08/tomcat-configurable-session-timeout-per.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEUBR34yeip7ImA9WhdREk4.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-7994072129897872158</id><published>2011-08-01T17:04:00.000-05:00</published><updated>2011-08-01T17:04:16.092-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-01T17:04:16.092-05:00</app:edited><title>Tomcat printing catalina pid</title><content type="html">If you are hosting more then one tomcats on a physical box in production then lot of times you might want to see the process id of running instance. We dump jstacks/top command output in a folder every 5 minutes and this helps in correlating it. Here is a sample code to dump tomcat pid.&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;pre&gt; public String getJvmProcessid() throws IOException {
  String pid = null;
  File pidFile = new File(System.getenv("CATALINA_PID"));
  if(pidFile.exists()) {
   FileInputStream fin = new FileInputStream(pidFile);
   List&lt;String&gt; lines = IOUtils.readLines(fin);
   fin.close();
   pid = StringUtils.join(lines.toArray());
  }
  return pid;
 }
&lt;/pre&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-7994072129897872158?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/n_0ybMBB4VuMGOfr__ut1NIpqbE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/n_0ybMBB4VuMGOfr__ut1NIpqbE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/n_0ybMBB4VuMGOfr__ut1NIpqbE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/n_0ybMBB4VuMGOfr__ut1NIpqbE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/jYyK9ppRxUM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/7994072129897872158/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/08/tomcat-printing-catalina-pid.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/7994072129897872158?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/7994072129897872158?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/jYyK9ppRxUM/tomcat-printing-catalina-pid.html" title="Tomcat printing catalina pid" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/08/tomcat-printing-catalina-pid.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0AHQXYyeCp7ImA9WhdREE0.&quot;"><id>tag:blogger.com,1999:blog-5003701650524272230.post-5329539319371850043</id><published>2011-07-29T23:55:00.000-05:00</published><updated>2011-07-29T23:55:30.890-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-29T23:55:30.890-05:00</app:edited><title>Mysql auto audit column</title><content type="html">Thanks to my colleague Deepak, today I learnt a new thing. If you want a column in your table like lastModifiedTime that gets inserted when the row is created and also auto updated whenever someone updates the row then traditionally the only way to do this was to use a trigger. I have used oracle for 4-5 years so I thought this is not possible to do in DDL and the trigger is the only way. But Mysql has this magic. You can create a column like&lt;br /&gt;
&lt;br /&gt;
 lastModifiedTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP  ON UPDATE CURRENT_TIMESTAMP,&lt;br /&gt;
&lt;br /&gt;
And this column will have current datetime on insert and will get updated with current datetime anytime a mutation to that row occurs. Wow no more triggers and this column is self maintained so no more worry about some dba disabling the trigger and did the update to get data inserted quickly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5003701650524272230-5329539319371850043?l=neopatel.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/1k3amkXkQPFwuGlf4S-GtKRHTE8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1k3amkXkQPFwuGlf4S-GtKRHTE8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/1k3amkXkQPFwuGlf4S-GtKRHTE8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1k3amkXkQPFwuGlf4S-GtKRHTE8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ProgrammingFunAtStartup/~4/CdXpgZ900UA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://neopatel.blogspot.com/feeds/5329539319371850043/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://neopatel.blogspot.com/2011/07/mysql-auto-audit-column.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/5329539319371850043?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5003701650524272230/posts/default/5329539319371850043?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ProgrammingFunAtStartup/~3/CdXpgZ900UA/mysql-auto-audit-column.html" title="Mysql auto audit column" /><author><name>Kalpesh Patel</name><uri>http://www.blogger.com/profile/05753943463214172718</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://neopatel.blogspot.com/2011/07/mysql-auto-audit-column.html</feedburner:origLink></entry></feed>

