radioAe6rt

Creating signed tags in git

leave a comment »

Written by radioae6rt

September 29, 2011 at 3:51 pm

Posted in Uncategorized

Tomcat7 port of distributed session manager

leave a comment »

Jon Brisbin wrote a super-clean Tomcat6 distributed session manager based on RabbitMQ. If you want to read clean code, read that stuff. It’s beautiful.

https://github.com/jbrisbin/vcloud

I ported the session manager to Tomcat7, here:

https://github.com/ae6rt/vcloud/tree/Tomcat7

Written by radioae6rt

August 20, 2011 at 10:41 am

Posted in Uncategorized

Caching Struts Tiles

leave a comment »

This is not an easy nut to crack, but if you want to cache Struts Tiles, you can clone the Tiles JSP InsertTag to suit the need. Around where doInclude(page) appears, render the referenced JSP page using an HTTPResponseWrapper, and ehcache the result before writing it to the tag pageContext writer. You might also consider augmenting the tile controller with a getCacheKey() method that returns a rich cache key in the form of a java.lang.Object with judiciously implemented overrides of equals() and hashcode(). Then, in the tag code, you can get a reference to the controller and therefore to getCacheKey() and cache the rendered-in-place content.

Written by radioae6rt

July 30, 2011 at 12:43 pm

Posted in Uncategorized

Java TimeUUID vs UUID.randomUUID()

with one comment

This is a great video of SriSatish Ambati discussing a number of useful Java garbage collection and concurrency issues

Among the many things I learned: at 38:00, use TimeUUID instead of UUID.randomUUID(). The latter is affected by SHA overhead and filesystem calls to /dev/urandom, while the former is not.

Here’s a reference to where you can find an implementation for TimeUUID:

http://wiki.apache.org/cassandra/FAQ#working_with_timeuuid_in_java

Nice.

Written by radioae6rt

June 29, 2011 at 5:24 pm

Posted in Uncategorized

EL vs. JSTL in JSP pages

leave a comment »

I recently had a chance to examine the difference between using JSTL tags and Expression Language (EL) in outputting content in JSPs.

For these two lines of JSP code that output the same content:

<body><c:out value="${header['host']}"/></body>   // JSTL

and

<body>${header["host"]}</body>   // EL

the following diff obtains in the generated JSP Java source code:

bmac:jstlvsel> diff --suppress-common-lines -y jstl_jsp.java el_jsp.java  
  private org.apache.jasper.runtime.TagHandlerPool _005fjspx_ <
							      <
    _005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fno <
    _005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fno <
      if (_jspx_meth_c_005fout_005f0(_jspx_page_context))     |	      out.write((java.lang.String) org.apache.jasper.runtime.
        return;						      <
							      <
  private boolean _jspx_meth_c_005fout_005f0(javax.servlet.js <
          throws java.lang.Throwable {			      <
    javax.servlet.jsp.PageContext pageContext = _jspx_page_co <
    javax.servlet.jsp.JspWriter out = _jspx_page_context.getO <
    //  c:out						      <
    org.apache.taglibs.standard.tag.rt.core.OutTag _jspx_th_c <
    _jspx_th_c_005fout_005f0.setPageContext(_jspx_page_contex <
    _jspx_th_c_005fout_005f0.setParent(null);		      <
    // /out.jsp(4,6) name = value type = null reqTime = true  <
    _jspx_th_c_005fout_005f0.setValue((java.lang.Object) org. <
    int _jspx_eval_c_005fout_005f0 = _jspx_th_c_005fout_005f0 <
    if (_jspx_th_c_005fout_005f0.doEndTag() == javax.servlet. <
      _005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005f <
      return true;					      <
    }							      <
    _005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fno <
    return false;					      <
  }	

where the first file is the JSTL version and the second file the EL version.

As one can see, the JSTL version traverses the JSTL tag handling layer before output, while EL goes straight to output. It’s no secret that EL is more efficient for simple output tasks, but it’s always good to see why.

Written by radioae6rt

June 29, 2011 at 6:04 am

Posted in Uncategorized

JSTL 1.2 that GlassFish v2 uses

leave a comment »

I believe this is the JSTL 1.2 implementation that GlassFish v2 uses:

https://svn.java.net/svn/jstl~svn/tags/jstl-1.2

Written by radioae6rt

June 23, 2011 at 5:01 pm

Posted in Uncategorized

Preparing Tomcat instances with Groovy

leave a comment »

Zemian Deng has a nice set of Groovy scripts for dealing with Java webapps.  He also has a good boilerplate script for preparing Tomcat server.xml config:

http://docs.codehaus.org/download/attachments/16580630/NewTomcatInstance.groovy

Written by radioae6rt

June 23, 2011 at 6:08 am

Posted in Uncategorized

Follow

Get every new post delivered to your Inbox.