<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-548519990128655859</id><updated>2011-11-27T16:34:13.490-08:00</updated><category term='Hibernate'/><category term='MS-SQL'/><category term='Webservices'/><category term='C# .NET'/><category term='Struts'/><category term='Nudgets'/><category term='Exception'/><category term='MySQL'/><category term='JAVA'/><category term='Thougths'/><title type='text'>Tech-Rapids</title><subtitle type='html'>Rapid is a section of a river where the river bed has a relatively steep gradient causing an increase in water velocity and turbulence.

     This blog aims to tackle similar rapids for it's readers in field of software technology by presenting many aspects of tools languages latest trends tips and features of various technologies.
     Many of these articles are related to hands-on problems faced and solved during the course of my experience, which might also help another distressed soul.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-7297141470399357709</id><published>2011-03-20T10:34:00.000-07:00</published><updated>2011-03-20T11:55:20.957-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Webservices'/><title type='text'>Webservices - Part-2</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Creating and consuming java webservices.&lt;br /&gt;&lt;br /&gt;Creating your own simple webservice from java classes&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;create a Java project in eclipse or whichever IDE you are using&lt;/li&gt;&lt;li&gt;create following package &lt;span style="font-weight: bold;"&gt;webservicesTest.simplews&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Define two java classes Simple1.java and Simple2.java&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Simple1.java components addNumbers(a, b) and subtractNumbers(a,b)&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Simple2.java&lt;/span&gt;&lt;span&gt; components multiplyNumbers(a, b) and divideNumbers(a, b)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Create webservices.xml for defining the xsd and operations of above methods to expose&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Build web-services using ant tags as defined under build.xml (refer code)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Use ANT tags for creating .ear and .war types to deploy webservice (refer code)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Deploy the webservice to your weblogic or tomcat application server&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Redeploy your application server&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Invoke the WS methods using Dynamic (explained below refer WSClient.java)&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:180%;"&gt;Code:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Simple1.java&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;package webservicesTest.simplews;&lt;br /&gt;&lt;br /&gt;public final class Simple1 {&lt;br /&gt;&lt;br /&gt;public int addNumbers(int a, int b) {&lt;br /&gt;System.out.println("a, b: "+a+", "+ b);&lt;br /&gt;return (a+b);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public int subtractNumbers(int a, int b) {&lt;br /&gt;System.out.println("a, b: "+a+", "+ b);&lt;br /&gt;return (b-a);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Simple2.java&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;package webservicesTest.simplews;&lt;br /&gt;&lt;br /&gt;public final class Simple2 {&lt;br /&gt;&lt;br /&gt;public int multiplyNumbers(int a, int b) {&lt;br /&gt;System.out.println("a, b: "+a+", "+ b);&lt;br /&gt;return (a*b);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public int divideNumbers(int a, int b) {&lt;br /&gt; System.out.println("a, b: "+a+", "+ b);&lt;br /&gt; if(a==0) return 0;&lt;br /&gt; return (b/a);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;web-services.xml&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/-AGDMsQmFvjw/TYZM52xu03I/AAAAAAAAAWk/mOcMXjvxe6g/s1600/webservice.gif"&gt;&lt;img style="float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 400px; height: 251px;" src="http://2.bp.blogspot.com/-AGDMsQmFvjw/TYZM52xu03I/AAAAAAAAAWk/mOcMXjvxe6g/s400/webservice.gif" alt="" id="BLOGGER_PHOTO_ID_5586236944640037746" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;application.xml&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/-6dAu6sEEd80/TYZNNRfSsfI/AAAAAAAAAWs/F_DVm25Pu3o/s1600/application.gif"&gt;&lt;img style="float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 301px; height: 162px;" src="http://4.bp.blogspot.com/-6dAu6sEEd80/TYZNNRfSsfI/AAAAAAAAAWs/F_DVm25Pu3o/s400/application.gif" alt="" id="BLOGGER_PHOTO_ID_5586237278227968498" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Build.xml&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/-1zhDHFbYyQc/TYZNalmP6nI/AAAAAAAAAW0/F-6vJZZ2C-E/s1600/build.gif"&gt;&lt;img style="float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 400px; height: 382px;" src="http://2.bp.blogspot.com/-1zhDHFbYyQc/TYZNalmP6nI/AAAAAAAAAW0/F-6vJZZ2C-E/s400/build.gif" alt="" id="BLOGGER_PHOTO_ID_5586237506964154994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;in the root of your project folder two files will be created on running above build.xml&lt;br /&gt;simplews.ear and simplews.war&lt;br /&gt;you can use any of the above files to deploy into your application server&lt;br /&gt;&lt;br /&gt;after deploying the ws must be accessible using below uri&lt;br /&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=548519990128655859&amp;amp;postID=7297141470399357709#"&gt;http://localhost:7001/simplews/Simplicity&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;WSDL&lt;br /&gt;&lt;/span&gt;http://localhost:7001/simplews/Simplicity?wsdl&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Now access your webservice and invoke it's methods from a java client&lt;br /&gt;This is dynamic invocation where you donot need to make a client or stub for invoking ws methods and can do directly using the http url.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;WSClient.java&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;package webservicesTest.simplews;&lt;br /&gt;&lt;br /&gt;import javax.xml.rpc.Call;&lt;br /&gt;import javax.xml.rpc.ParameterMode;&lt;br /&gt;import javax.xml.rpc.ServiceFactory;&lt;br /&gt;import javax.xml.rpc.Service;&lt;br /&gt;import javax.xml.namespace.QName;&lt;br /&gt;&lt;br /&gt;public final class WSClient {&lt;br /&gt;&lt;br /&gt;private static String TARGET_NAMESPACE =&lt;br /&gt;"http://localhost:7001/example/wstest/simplews";&lt;br /&gt;&lt;br /&gt;public static void main(String[] argv) throws Exception {&lt;br /&gt;&lt;br /&gt;// Setup the global JAX-RPC service factory&lt;br /&gt;System.setProperty( "javax.xml.rpc.ServiceFactory",&lt;br /&gt;"weblogic.webservice.core.rpc.ServiceFactoryImpl");&lt;br /&gt;&lt;br /&gt;String url = "http://localhost:7001//simplews/Simplicity";&lt;br /&gt;&lt;br /&gt;System.out.println("Calling Web Service at: "+url);&lt;br /&gt;System.out.println("");&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//create service factory&lt;br /&gt;ServiceFactory factory = ServiceFactory.newInstance();&lt;br /&gt;&lt;br /&gt;QName serviceName   = new QName(TARGET_NAMESPACE, "simplews");&lt;br /&gt;QName portName      = new QName(TARGET_NAMESPACE, "simplewsPort");&lt;br /&gt;&lt;br /&gt;//create service&lt;br /&gt;Service service = factory.createService(serviceName);&lt;br /&gt;&lt;br /&gt;//create call&lt;br /&gt;Call subtraction = service.createCall();&lt;br /&gt;Call multiplication    = service.createCall();&lt;br /&gt;&lt;br /&gt;//set port and operation name&lt;br /&gt;subtraction.setPortTypeName(portName);&lt;br /&gt;subtraction.setOperationName(new QName("subtractNumbers"));&lt;br /&gt;multiplication.setPortTypeName(portName);&lt;br /&gt;multiplication.setOperationName(new QName("multiplyNumbers"));&lt;br /&gt;&lt;br /&gt;//add parameters&lt;br /&gt;subtraction.addParameter("num1",&lt;br /&gt;           new QName("http://www.w3.org/2001/XMLSchema", "int"),&lt;br /&gt;           ParameterMode.IN);&lt;br /&gt;subtraction.addParameter("num2",&lt;br /&gt; new QName("http://www.w3.org/2001/XMLSchema", "int"),&lt;br /&gt; ParameterMode.IN);&lt;br /&gt;subtraction.setReturnType(new QName( "http://www.w3.org/2001/XMLSchema","int") );&lt;br /&gt;&lt;br /&gt;multiplication.addParameter("num1",&lt;br /&gt;           new QName("http://www.w3.org/2001/XMLSchema", "int"),&lt;br /&gt;           ParameterMode.IN);&lt;br /&gt;multiplication.addParameter("num2",&lt;br /&gt; new QName("http://www.w3.org/2001/XMLSchema", "int"),&lt;br /&gt; ParameterMode.IN);&lt;br /&gt;multiplication.setReturnType(new QName( "http://www.w3.org/2001/XMLSchema","int") );&lt;br /&gt;&lt;br /&gt;//set end point address&lt;br /&gt;subtraction.setTargetEndpointAddress(url);&lt;br /&gt;multiplication.setTargetEndpointAddress(url);&lt;br /&gt;&lt;br /&gt;Integer x1 = (Integer) subtraction.invoke(&lt;br /&gt;   new Object [] { new Integer(123), new Integer(10) }&lt;br /&gt; );&lt;br /&gt;System.out.println("** subtraction returned: "+x1);&lt;br /&gt;&lt;br /&gt;Integer x2 = (Integer) multiplication.invoke(&lt;br /&gt;new Object [] { new Integer(123), new Integer(10) }&lt;br /&gt;);&lt;br /&gt;System.out.println("** multiplication returned: "+x2);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-7297141470399357709?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/7297141470399357709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2011/03/webservices-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/7297141470399357709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/7297141470399357709'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2011/03/webservices-part-2.html' title='Webservices - Part-2'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-AGDMsQmFvjw/TYZM52xu03I/AAAAAAAAAWk/mOcMXjvxe6g/s72-c/webservice.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-4810740502876212616</id><published>2011-03-20T08:29:00.000-07:00</published><updated>2011-03-20T09:47:16.679-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Webservices'/><title type='text'>Webservices - Part-1</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Creating and consuming java webservices.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What is a Webservice ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;            A web service is a collection of protocols and standards used for exchanging data between applications or systems. WebServices are published, described and located over the internet.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Characteristics of a Webservice.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;         A Web Service is accessible over the internet or intranet both.&lt;br /&gt;          Web Services communicate using platform-independent and language-neutral Web protocols such as XML-RPC, HTTP or SOAP.&lt;br /&gt;          A Web Service shares schemas and contracts/interface that can be called from another program.&lt;br /&gt;          A Web Service is registered and can be located through a Web Service Registry or UDDI.&lt;br /&gt;          A Web Service supports loosely coupled connections between two different systems or applications.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Technologies associated with a Webservice.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;         XML (eXtensible Markup Language)&lt;br /&gt;                     It's a markup language that underlies most of the specifications used for Web services. It is also platform neutral and can be used by any system or application.&lt;br /&gt;  &lt;br /&gt;            SOAP (Simple Object Access Protocol)&lt;br /&gt;                     SOAP is a network, transport, and programming language and platform neutral protocol that allows a client to call a remote service. The request response message format is always in XML format.&lt;br /&gt;&lt;br /&gt;            WSDL (Web services description language)&lt;br /&gt;                     An XML-based interface and implementation description language. The service provider uses a WSDL document in order to specify the operations a Web service exposes.&lt;br /&gt;  &lt;br /&gt;            UDDI (universal description, discovery, and integration)&lt;br /&gt;                     Both a client-side API and a SOAP-based server implementation that can be used to store and retrieve information on service providers and Web services.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Advantages of Web services&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;    &lt;/span&gt;         WebServices communicate of over http protocol and can easily cross network boundaries. These are easy to integrate and use.&lt;br /&gt;            Web services support only the data types defined in the XSD (XML Schema definition), limiting the number of objects that can be serialized. This makes them interoperable across platforms.&lt;br /&gt;            Highly reliable due to the fact that Web services are always hosted in controlled environments.&lt;br /&gt;            Provides extensibility by allowing us to intercept the SOAP messages during the serialization and deserialization stages.&lt;br /&gt;            Easy to create, deploy and consume.&lt;br /&gt;&lt;br /&gt;Continue reading to create your own simple webservice.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-4810740502876212616?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/4810740502876212616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2011/03/webservices-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/4810740502876212616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/4810740502876212616'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2011/03/webservices-part-1.html' title='Webservices - Part-1'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-8644925256930135268</id><published>2011-01-14T08:26:00.001-08:00</published><updated>2011-01-14T08:26:56.895-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Exception'/><title type='text'>SocketException</title><content type='html'>java.net.SocketException: Socket closed&lt;br /&gt; at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:104)&lt;br /&gt; at java.net.SocketOutputStream.write(SocketOutputStream.java:141)&lt;br /&gt; at weblogic.servlet.internal.ChunkUtils.writeChunkTransfer(ChunkUtils.java:234)&lt;br /&gt; at weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java:207)&lt;br /&gt; at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:302)&lt;br /&gt; at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:377)&lt;br /&gt; at weblogic.servlet.internal.ChunkOutput.write(ChunkOutput.java:247)&lt;br /&gt; at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:125)&lt;br /&gt; at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:184)&lt;br /&gt; at com.utils.FileDownload.downloadFile(FileDownload.java:133)&lt;br /&gt; at com.utils.ExcelGenerator.downloadExcel(ExcelGenerator.java:456)&lt;br /&gt; at com.utils.ExcelGenerator.crearExcellPoi(ExcelGenerator.java:372)&lt;br /&gt; at com.utils.ExcelGenerator.crearExcell(ExcelGenerator.java:76)&lt;br /&gt; at com.ExportacionCtrl.procesar(ExportacionCtrl.java:299)&lt;br /&gt; at com.BaseServlet.doPost(ControladorBaseServlet.java:160)&lt;br /&gt; at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)&lt;br /&gt; at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)&lt;br /&gt; at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1104)&lt;br /&gt; at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:430)&lt;br /&gt; at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:324)&lt;br /&gt; at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5764)&lt;br /&gt; at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:690)&lt;br /&gt; at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3230)&lt;br /&gt; at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2642)&lt;br /&gt; at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:262)&lt;br /&gt; at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:224)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-8644925256930135268?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/8644925256930135268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2011/01/socketexception.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/8644925256930135268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/8644925256930135268'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2011/01/socketexception.html' title='SocketException'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-2292813744640772968</id><published>2010-07-25T23:28:00.000-07:00</published><updated>2010-07-26T00:02:32.861-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Nudgets'/><title type='text'>Downloading file the right way</title><content type='html'>Often I had faced this problem while providing a file download functionality that&lt;br /&gt;instead of providing a prompt the file gets opened in the browser itself.&lt;br /&gt;This is because for known MIME (Multipurpose Internet Mail Extensions) types such as Microsoft Word ("application/ms-word") or images(application/gif, application/jpeg), the default behavior is to open the document in browser itself. Specially in cases of text or csv files such behaviour is observed.&lt;br /&gt;&lt;br /&gt;So the objective is you serve a document from a Web server, and it immediately prompts to save that document directly to the user's disk, without opening it in the browser.&lt;br /&gt;&lt;br /&gt;It is a matter of setting the right content-disposition and file-options. Below code should be a help to anybody facing such a problem&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;ServletOutputStream sos = null;&lt;br /&gt;// this can be a path of your repository or a relative path&lt;br /&gt;String uploadedFilePath = "C:/";&lt;br /&gt;&lt;br /&gt;String fileName = request.getParameter("filename");&lt;br /&gt;File file = new File( uploadedFilePath +  "/" + fileName );&lt;br /&gt;FileInputStream fis = new FileInputStream(file);&lt;br /&gt;int size= (int) file.length();&lt;br /&gt;        &lt;br /&gt;// determine the mime-type for safe downloading&lt;br /&gt;String ext = fileName.substring(fileName.indexOf("."), fileName.length());&lt;br /&gt;ext = ext.toLowerCase();&lt;br /&gt;&lt;br /&gt;if(ext.endsWith(".jpg") || ext.endsWith(".jpeg"))&lt;br /&gt; {&lt;br /&gt;  response.setContentType("image/jpeg");&lt;br /&gt; }&lt;br /&gt;else if(ext.endsWith(".gif"))&lt;br /&gt; {&lt;br /&gt;  response.setContentType("image/gif");&lt;br /&gt; }&lt;br /&gt;else if(ext.endsWith(".pdf"))&lt;br /&gt; {&lt;br /&gt;  response.setContentType("application/pdf");&lt;br /&gt; }&lt;br /&gt;else if(ext.endsWith(".csv"))&lt;br /&gt; {&lt;br /&gt;  response.setContentType("application/csv");&lt;br /&gt; }&lt;br /&gt;else&lt;br /&gt; {&lt;br /&gt;  response.setContentType("application/octet-stream");&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;response.setHeader("Content-disposition:","attachment; filename=" + fileName );&lt;br /&gt;response.setHeader("cache-control", "no-cache"); &lt;br /&gt;        &lt;br /&gt;byte[] tmpBuffer=null;&lt;br /&gt;sos =  response.getOutputStream();&lt;br /&gt;if ( size &gt; 0) &lt;br /&gt;{&lt;br /&gt; tmpBuffer = new byte[size];&lt;br /&gt; fis.read(tmpBuffer);&lt;br /&gt; sos.write(tmpBuffer);&lt;br /&gt; fis.close();&lt;br /&gt;}&lt;br /&gt;sos.flush();&lt;br /&gt;sos.close();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Do check-out this post on a &lt;a href="http://tech-rapids.blogspot.com/2009/05/javalangillegalstateexception.html"&gt;related exception &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Happy Coding !!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-2292813744640772968?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/2292813744640772968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2010/07/downloading-file-right-way.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/2292813744640772968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/2292813744640772968'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2010/07/downloading-file-right-way.html' title='Downloading file the right way'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-63614402657701924</id><published>2010-07-14T05:30:00.000-07:00</published><updated>2010-07-14T05:36:47.237-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Thougths'/><title type='text'>MySQL Roadmap from Oracle</title><content type='html'>Few days back I was going through this article on a website which talked about Edward Screven, Oracle's chief corporate architect's message at O'Reilly MySQL Conference in Santa Clara, California. The oracle chief architect took the stage with a simple message : "MySQL matters to Oracle"&lt;br /&gt;&lt;br /&gt;Performance boost, as well as several other planned enhancements, will be included in both the community and commercial editions of MySQL. However some features like hot backup, will be only in the commercial edition of MySQL.&lt;br /&gt;&lt;br /&gt;While Screven said that Oracle wants to run MySQL definitely as a business to make money, he emphasized that he and others at the company liked the way the open source community edition made it easy for people to start projects. &lt;br /&gt;He also said that "We're really focused on ensuring that MySQL becomes a better product and appeals to our customers. What we're fundamentally selling here is support."&lt;br /&gt;&lt;br /&gt;The article can be found &lt;a href="http://www.itworldcanada.com/news/oracle-chief-architect-unveils-mysql-roadmap/140415-pg2" target="_new"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Although I do believe what Screven says about the future of MySQL that it will stay open source. But there were some reds I noticed ... &lt;br /&gt;&lt;br /&gt;Firstly, how long will MySQL stay open source given that Oracle is looking at ways MySQL can be profitable to the company.&lt;br /&gt;Secondly, the biggest problem faced by open source community is support in itself. So when Oracle says that it will be selling support then the chances of open source community getting technical support within budget diminishes.&lt;br /&gt;&lt;br /&gt;Although the company maintains that main features will always be part of the community edition but will this sustain the competition from it's enterprize edition counterpart ?&lt;br /&gt;&lt;br /&gt;I think these are some of the thoughts that provoked some ex-employees of MySQL and community members to create forked versions of the MySQL core tool. For example MariaDB and Drizzle both are experimenting with different data storage engines and other enhancements.&lt;br /&gt;&lt;br /&gt;Just thinking!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-63614402657701924?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/63614402657701924/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2010/07/mysql-roadmap-from-oracle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/63614402657701924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/63614402657701924'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2010/07/mysql-roadmap-from-oracle.html' title='MySQL Roadmap from Oracle'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-7359234486785817661</id><published>2009-11-03T20:37:00.000-08:00</published><updated>2009-11-03T20:47:11.272-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Exception'/><title type='text'>Struts2: type Exception report</title><content type='html'>&lt;h1&gt;HTTP Status 500 - &lt;/h1&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;p&gt;&lt;b&gt;type&lt;/b&gt; Exception report&lt;/p&gt;&lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;The server encountered an internal error () that prevented it from fulfilling this request.&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;exception&lt;/b&gt; &lt;pre&gt;javax.servlet.ServletException: Unable to instantiate Action, com.action.LoginAction,  defined for 'login' in namespace '/'null - action - file:/C:/apache-tomcat-6.0.14/webapps/WebProject/WEB-INF/classes/struts.xml:23:75&lt;br /&gt; org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:518)&lt;br /&gt; org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)&lt;br /&gt;&lt;/pre&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;root cause&lt;/b&gt; &lt;pre&gt;Unable to instantiate Action, com.action.LoginAction,  defined for 'login' in namespace '/'null - action - file:/C:/apache-tomcat-6.0.14/webapps/WebProject/WEB-INF/classes/struts.xml:23:75&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:289)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:360)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:78)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.&amp;lt;init&amp;gt;(DefaultActionInvocation.java:70)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.&amp;lt;init&amp;gt;(DefaultActionInvocation.java:66)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)&lt;br /&gt; org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)&lt;br /&gt; org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:497)&lt;br /&gt; org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)&lt;br /&gt;&lt;/pre&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;root cause&lt;/b&gt; &lt;pre&gt;java.lang.NullPointerException&lt;br /&gt; com.LoginAction.&amp;lt;init&amp;gt;(LoginAction.java:35)&lt;br /&gt; sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)&lt;br /&gt; sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)&lt;br /&gt; sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)&lt;br /&gt; java.lang.reflect.Constructor.newInstance(Constructor.java:513)&lt;br /&gt; java.lang.Class.newInstance0(Class.java:355)&lt;br /&gt; java.lang.Class.newInstance(Class.java:308)&lt;br /&gt; com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:121)&lt;br /&gt; com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:152)&lt;br /&gt; com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:141)&lt;br /&gt; com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:111)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:270)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:360)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:78)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.&amp;lt;init&amp;gt;(DefaultActionInvocation.java:70)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.&amp;lt;init&amp;gt;(DefaultActionInvocation.java:66)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)&lt;br /&gt; org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)&lt;br /&gt; org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:497)&lt;br /&gt; org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)&lt;br /&gt;&lt;/pre&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;note&lt;/b&gt; &lt;u&gt;The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.&lt;/u&gt;&lt;/p&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;h3&gt;Apache Tomcat/6.0.14&lt;/h3&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-7359234486785817661?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/7359234486785817661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2009/11/struts2-type-exception-report.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/7359234486785817661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/7359234486785817661'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/11/struts2-type-exception-report.html' title='Struts2: type Exception report'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-3287516981187713994</id><published>2009-10-15T10:26:00.000-07:00</published><updated>2009-10-24T23:09:22.478-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Exception'/><title type='text'>FreeMarker template error!</title><content type='html'>FreeMarker template error!&lt;br /&gt;&lt;br /&gt;Expression parameters.doubleId is undefined on line 47, column 108 in template/simple/optiontransferselect.ftl.&lt;br /&gt;The problematic instruction:&lt;br /&gt;----------&lt;br /&gt;==&gt; ${parameters.doubleId?html} [on line 47, column 106 in template/simple/optiontransferselect.ftl]&lt;br /&gt; in include "/${parameters.templateDir}/simple/optiontransferselect.ftl" [on line 2, column 1 in template/xhtml/optiontransferselect.ftl]&lt;br /&gt;----------&lt;br /&gt;&lt;br /&gt;Java backtrace for programmers:&lt;br /&gt;----------&lt;br /&gt;freemarker.core.InvalidReferenceException: Expression parameters.doubleId is undefined on line 47, column 108 in template/simple/optiontransferselect.ftl.&lt;br /&gt; at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)&lt;br /&gt; at freemarker.core.Expression.getStringValue(Expression.java:118)&lt;br /&gt; at freemarker.core.Expression.getStringValue(Expression.java:93)&lt;br /&gt; at freemarker.core.StringBuiltins$StringBuiltIn._getAsTemplateModel(StringBuiltins.java:71)&lt;br /&gt; at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)&lt;br /&gt; at freemarker.core.Expression.getStringValue(Expression.java:93)&lt;br /&gt; at freemarker.core.DollarVariable.accept(DollarVariable.java:76)&lt;br /&gt; at freemarker.core.Environment.visit(Environment.java:196)&lt;br /&gt; at freemarker.core.MixedContent.accept(MixedContent.java:92)&lt;br /&gt; at freemarker.core.Environment.visit(Environment.java:196)&lt;br /&gt; at freemarker.core.IfBlock.accept(IfBlock.java:82)&lt;br /&gt; at freemarker.core.Environment.visit(Environment.java:196)&lt;br /&gt; at freemarker.core.MixedContent.accept(MixedContent.java:92)&lt;br /&gt; at freemarker.core.Environment.visit(Environment.java:196)&lt;br /&gt; at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)&lt;br /&gt; at freemarker.core.Environment.visit(Environment.java:196)&lt;br /&gt; at freemarker.core.MixedContent.accept(MixedContent.java:92)&lt;br /&gt; at freemarker.core.Environment.visit(Environment.java:196)&lt;br /&gt; at freemarker.core.Environment.include(Environment.java:1375)&lt;br /&gt; at freemarker.core.Include.accept(Include.java:155)&lt;br /&gt; at freemarker.core.Environment.visit(Environment.java:196)&lt;br /&gt; at freemarker.core.MixedContent.accept(MixedContent.java:92)&lt;br /&gt; at freemarker.core.Environment.visit(Environment.java:196)&lt;br /&gt; at freemarker.core.Environment.process(Environment.java:176)&lt;br /&gt; at freemarker.template.Template.process(Template.java:232)&lt;br /&gt; at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:148)&lt;br /&gt; at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:530)&lt;br /&gt; at org.apache.struts2.components.UIBean.end(UIBean.java:484)&lt;br /&gt; at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)&lt;br /&gt; at org.apache.jsp.viewContent_jsp._jspx_meth_s_005foptiontransferselect_005f0(viewContent_jsp.java:215)&lt;br /&gt; at org.apache.jsp.viewContent_jsp._jspService(viewContent_jsp.java:108)&lt;br /&gt; at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)&lt;br /&gt; at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)&lt;br /&gt; at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)&lt;br /&gt; at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)&lt;br /&gt; at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)&lt;br /&gt; at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)&lt;br /&gt; at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)&lt;br /&gt; at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)&lt;br /&gt; at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:414)&lt;br /&gt; at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)&lt;br /&gt; at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)&lt;br /&gt; at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)&lt;br /&gt; at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)&lt;br /&gt; at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)&lt;br /&gt; at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)&lt;br /&gt; at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)&lt;br /&gt; at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)&lt;br /&gt; at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)&lt;br /&gt; at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)&lt;br /&gt; at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)&lt;br /&gt; at java.lang.Thread.run(Thread.java:619)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-3287516981187713994?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/3287516981187713994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2009/10/freemarker-template-error.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/3287516981187713994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/3287516981187713994'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/10/freemarker-template-error.html' title='FreeMarker template error!'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-1317744075353062355</id><published>2009-10-07T02:33:00.000-07:00</published><updated>2009-10-07T04:00:57.188-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Exception'/><title type='text'>Struts 2 Exception : No result defined for action LoginAction</title><content type='html'>No result defined for action com.action.LoginAction and result input - action - file:struts.xml:10:75&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:345)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)&lt;br /&gt; com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)&lt;br /&gt; org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)&lt;br /&gt; com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; com.opensymphony.xwork2.interceptor.ParametersInterceptor.intercept(ParametersInterceptor.java:161)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; com.opensymphony.xwork2.interceptor.PrepareInterceptor.intercept(PrepareInterceptor.java:115)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)&lt;br /&gt; com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)&lt;br /&gt; com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)&lt;br /&gt; org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)&lt;br /&gt; org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:507)&lt;br /&gt; org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-1317744075353062355?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/1317744075353062355'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/1317744075353062355'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/10/struts-2-exception-no-result-defined.html' title='Struts 2 Exception : No result defined for action LoginAction'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-138496007357946933</id><published>2009-09-29T21:51:00.000-07:00</published><updated>2009-09-29T22:19:21.029-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C# .NET'/><title type='text'>Handling Cookies with WebRequest Class</title><content type='html'>&lt;p&gt;WebRequest is an important class for establishing http connections programatically and fetching html page. You might well be aware about it's power. However I will be focussing on one limitation and a possible work-around.&lt;/p&gt;&lt;p&gt;While fetching some html content I hit upon a problem where it was expected for cookies to be enabled by the browser. Since I was making a hit using WebRequest class i was perplexed as to how to resolve it, untill better sense prevailed and I got the below solution.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Handling Cookies with WebRequest class&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;// Open a connection&lt;br /&gt;HttpWebRequest WebRequestObject = (HttpWebRequest)HttpWebRequest.Create(Url); &lt;/p&gt;&lt;p&gt;// Set the Cookie Container under WebRequest object as  a property&lt;br /&gt;CookieContainer cookieJar = new CookieContainer();&lt;br /&gt;WebRequestObject.CookieContainer = cookieJar;&lt;/p&gt;&lt;p&gt;// continue with your fetch&lt;/p&gt;&lt;p&gt;// A handy property is it seems that some page might take eternity to respond&lt;br /&gt;WebRequestObject.Timeout = 5*60*1000; // (5 seconds) integer value in milliseconds&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-138496007357946933?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/138496007357946933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/138496007357946933'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/09/handling-cookies-with-webrequest-class.html' title='Handling Cookies with WebRequest Class'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-8146847672678844769</id><published>2009-09-07T22:10:00.001-07:00</published><updated>2009-09-07T22:17:29.921-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C# .NET'/><title type='text'>Updating auto-incremented id from SqlDataAdapter back into datatable</title><content type='html'>consider a table in your database .. else run the script to create&lt;br /&gt;&lt;br /&gt;Create table person (&lt;br /&gt;id int identity(1,1) not null,&lt;br /&gt;name varchar(100) not null,&lt;br /&gt;age int not null&lt;br /&gt;)&lt;br /&gt;-----------------&lt;br /&gt;// C# sample code, should be in a proper .cs file to be executed&lt;br /&gt;&lt;br /&gt;// some imports&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;// more imports&lt;br /&gt;&lt;br /&gt;// ....&lt;br /&gt;// some code&lt;br /&gt;String connectionString = ""Persist Security Info=False;User ID=sa;Password=sa;Initial Catalog=master;Data Source=localhost;&lt;br /&gt;&lt;br /&gt;// this is the query which we will require&lt;br /&gt;String query = "insert into person (name, age) values (@NAME, @AGE);select @ROWID = @@identity";&lt;br /&gt;&lt;br /&gt;DataTable dt = new DataTable();&lt;br /&gt;dt.Columns.Add("ID", System.Type.GetType("System.Int32"));&lt;br /&gt;dt.Columns.Add("NAME", System.Type.GetType("System.String"));&lt;br /&gt;dt.Columns.Add("AGE", System.Type.GetType("System.Int32"));&lt;br /&gt;&lt;br /&gt;dt.Rows.Add(new object[] {-1, "max", 10});&lt;br /&gt;&lt;br /&gt;// check dt.Rows[0]["ID"] value it will be -1&lt;br /&gt;&lt;br /&gt;// inserting the above table into database&lt;br /&gt;SqlDataAdapter myAdapter =new SqlDataAdapter();&lt;br /&gt;SqlConnection myConnection = new SqlConnection(ConnectionString);&lt;br /&gt;myConnection.Open();&lt;br /&gt;SqlCommand cmd = new SqlCommand(query, myConnection);   &lt;br /&gt;SqlParameter parmRowId =&lt;br /&gt;cmd.Parameters.Add("@ROWID",DbType.Int32);&lt;br /&gt;parmRowId.SourceColumn = "ID";&lt;br /&gt;parmRowId.SourceVersion = DataRowVersion.Original;&lt;br /&gt;parmRowId.Direction = ParameterDirection.Output;&lt;br /&gt;&lt;br /&gt;SqlParameter parmID =&lt;br /&gt;cmd.Parameters.Add("@NAME",DbType.Int32);&lt;br /&gt;parmID.SourceColumn = "NAME";&lt;br /&gt;parmID.SourceVersion = DataRowVersion.Original;&lt;br /&gt;&lt;br /&gt;SqlParameter parmID =&lt;br /&gt;cmd.Parameters.Add("@AGE",DbType.Int32);&lt;br /&gt;parmID.SourceColumn = "AGE";&lt;br /&gt;parmID.SourceVersion = DataRowVersion.Original;&lt;br /&gt;&lt;br /&gt;myAdapter.InsertCommand = cmd;&lt;br /&gt;// required to get back the auto-incrmented value&lt;br /&gt;cmd.UpdatedRowSource = UpdateRowSource.OutputParameters;&lt;br /&gt;myAdapter.Update(datatable);&lt;br /&gt;&lt;br /&gt;// now check dt.Rows[0]["ID"] value it should be 1 or some auto-incremented value&lt;br /&gt;// the above style can be used with your typed dataset too&lt;br /&gt;&lt;br /&gt;// ... more code&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-8146847672678844769?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/8146847672678844769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/8146847672678844769'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/09/updating-auto-incremented-id-from.html' title='Updating auto-incremented id from SqlDataAdapter back into datatable'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-4198943331556897518</id><published>2009-09-07T02:31:00.000-07:00</published><updated>2009-09-29T22:21:19.721-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MS-SQL'/><title type='text'>Fetching last auto-incremented identity value</title><content type='html'>There are 3 of different ways for fetching the updated identity column value.&lt;br /&gt;&lt;br /&gt;IDENT_CURRENT&lt;br /&gt;SCOPE_IDENTITY&lt;br /&gt;and @@IDENTITY&lt;br /&gt;each of the above have a similar role to play except for some subtle differences.&lt;br /&gt;One common tasks of theirs is that they return values inserted into IDENTITY columns.&lt;br /&gt;&lt;br /&gt;IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the value generated for a specific table in any session and any scope.&lt;br /&gt;SCOPE_IDENTITY and @@IDENTITY will return last identity values generated in any table in the current session. However, SCOPE_IDENTITY returns values inserted only within the current scope; @@IDENTITY is not limited to a specific scope.&lt;br /&gt;&lt;br /&gt;for details refer&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa259185(SQL.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/aa259185(SQL.80).aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-4198943331556897518?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/4198943331556897518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/4198943331556897518'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/09/fetching-updated-identity.html' title='Fetching last auto-incremented identity value'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-8748758997515002230</id><published>2009-09-03T04:37:00.000-07:00</published><updated>2009-09-03T04:41:39.430-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Nudgets'/><title type='text'>Programatically determining redirected URL</title><content type='html'>&lt;p&gt;In order to detect the redirect, you have to use setFollowRedirects(false). Otherwise, you end up on the redirected page anyway with a responseCode of 200. However you will have to navigate the redirected url yourself.&lt;/p&gt;&lt;p&gt;using java.net.HttpURLConnection&lt;/p&gt;&lt;p&gt;URL url = new URL(urlstring);&lt;br /&gt;// Determine if the url has redirected&lt;br /&gt;HttpURLConnection.setFollowRedirects(false);&lt;br /&gt;HttpURLConnection uc = (HttpURLConnection) url.openConnection();&lt;br /&gt;if(uc.getResponseCode() == 300  uc.getResponseCode() == 302)&lt;br /&gt;{&lt;br /&gt;String newUrl = uc.getHeaderField("Location");&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-8748758997515002230?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/8748758997515002230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/8748758997515002230'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/09/programatically-determining-redirected.html' title='Programatically determining redirected URL'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-3941091023980982368</id><published>2009-09-02T22:52:00.000-07:00</published><updated>2009-09-29T22:20:06.147-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JAVA'/><title type='text'>JAVA Regex</title><content type='html'>&lt;strong&gt;Regex to get all links from a html source&lt;/strong&gt;&lt;br /&gt;String patternString = "&amp;lt;a.*?&amp;gt;/a&amp;gt;"&lt;br /&gt;Pattern pattern = Pattern.compile(patternString, Pattern.MULTILINE Pattern.CANON_EQ Pattern.DOTALL Pattern.CASE_INSENSITIVE Pattern.UNICODE_CASE);Matcher matcher = pattern.matcher(pageContent);&lt;br /&gt;while (matcher.find()) {&lt;br /&gt;String extractedUrl = matcher.group(); System.out.println(extractedUrl)&lt;br /&gt;}&lt;br /&gt;String hRefPattern = "href=['\"](.*?)['\"]";&lt;br /&gt;// extracts the href link&lt;br /&gt;link = m.group(1);&lt;br /&gt;&lt;br /&gt;-----------------------------&lt;br /&gt;&lt;strong&gt;Regex to get all RSS/ATOM links from a html source&lt;/strong&gt;&lt;br /&gt;String patternRSS = "&amp;lt;link.*rss\\+xml.*href.*['\"]((.*?))['\"]&amp;gt;";&lt;br /&gt;Pattern pattern = Pattern.compile(patternRSS, Pattern.MULTILINE Pattern.CANON_EQ Pattern.CASE_INSENSITIVE Pattern.UNICODE_CASE);&lt;br /&gt;Matcher matcherRSS = pattern.matcher(pageContent);&lt;br /&gt;while (matcherRSS.find()) {&lt;br /&gt;String rssUrl = matcherRSS.group(2);&lt;br /&gt;System.out.println(rssUrl);&lt;br /&gt;}&lt;br /&gt;// likewise ...&lt;br /&gt;String patternATOM = "&amp;lt;link.*atom\\+xml.*href.*['\"]((.*?))['\"]&amp;gt;";&lt;br /&gt;&lt;br /&gt;------------------------------&lt;br /&gt;&lt;strong&gt;Get links from a RSS/ATOM source&lt;/strong&gt;&lt;br /&gt;String patternRSSLinks = "&amp;lt;link&amp;gt;(.*?)&amp;lt;/link&amp;gt;";&lt;br /&gt;Pattern pattern = Pattern.compile(patternRSSLinks, Pattern.MULTILINE Pattern.CANON_EQ Pattern.CASE_INSENSITIVE Pattern.UNICODE_CASE);&lt;br /&gt;Matcher matcherRSSLinks = pattern.matcher(rssXML);&lt;br /&gt;while (matcherRSSLinks.find()) {&lt;br /&gt;String link = matcherRSSLinks.group(1);&lt;br /&gt;System.out.println(link)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;---------------------------------&lt;br /&gt;&lt;strong&gt;Determining javascript presence in a html link and getting's it's value &lt;/strong&gt;&lt;br /&gt;// 1. check for presence of opendocument, openwindow and window.open methods&lt;br /&gt;// extract the relative value and form it's absolute urlString&lt;br /&gt;patternString = "(?:opendocumentopenwindowwindow\\.open)\\s*\\(['\"]((.*?))['\"]";&lt;br /&gt;Pattern pattern = Pattern.compile(patternString, Pattern.DOTALL Pattern.CASE_INSENSITIVE Pattern.UNICODE_CASE);&lt;br /&gt;Matcher matcher = pattern.matcher(href);&lt;br /&gt;if(matcher.find()) {&lt;br /&gt;javascriptPresenceDetected = true;&lt;br /&gt;javascriptHref = matcher.group(2);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// 2. if not caught by 1&lt;br /&gt;patternString = "(?:javascript:).*?\\(['\"]((.*?))['\"]";&lt;br /&gt;pattern = Pattern.compile(patternString, Pattern.DOTALL Pattern.CASE_INSENSITIVE Pattern.UNICODE_CASE);&lt;br /&gt;matcher = pattern.matcher(href);&lt;br /&gt;if(matcher.find()) {&lt;br /&gt;javascriptPresenceDetected = true;&lt;br /&gt;javascriptHref = matcher.group(2);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// 3. if not caught by 1 &amp;amp; 2&lt;br /&gt;patternString = "(?:onclick).*?\\(['\"]((.*?))['\"]";&lt;br /&gt;pattern = Pattern.compile(patternString, Pattern.DOTALL Pattern.CASE_INSENSITIVE Pattern.UNICODE_CASE);&lt;br /&gt;matcher = pattern.matcher(href);&lt;br /&gt;if(matcher.find()) {&lt;br /&gt;javascriptPresenceDetected = true;&lt;br /&gt;javascriptHref = matcher.group(2);&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-3941091023980982368?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/3941091023980982368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2009/09/java-regex.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/3941091023980982368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/3941091023980982368'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/09/java-regex.html' title='JAVA Regex'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-5379930369674708077</id><published>2009-08-27T22:13:00.000-07:00</published><updated>2009-08-30T21:16:51.452-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Exception'/><title type='text'>transaction.JDBCTransaction : CommunicationsException</title><content type='html'>[ERROR] [2009-08-28 10:29:02,676] [http-16080-3] [transaction.JDBCTransaction] - [JDBC begin failed]&lt;br /&gt;com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was58282 seconds ago.The last packet sent successfully to the server was 58282 seconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.&lt;br /&gt;at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)&lt;br /&gt;at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)&lt;br /&gt;at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)&lt;br /&gt;at java.lang.reflect.Constructor.newInstance(Constructor.java:513)&lt;br /&gt;at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)&lt;br /&gt;at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)&lt;br /&gt;at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3246)&lt;br /&gt;at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1917)&lt;br /&gt;at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)&lt;br /&gt;at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536)&lt;br /&gt;at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4874)&lt;br /&gt;at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:91)&lt;br /&gt;at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)&lt;br /&gt;at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:38)&lt;br /&gt;at com.firstrain.common.db.jpa.TransactionImpl.&lt;init&gt;(TransactionImpl.java:30)&lt;br /&gt;at com.firstrain.common.db.jpa.PersistenceProvider.newTxn(PersistenceProvider.java:51)&lt;br /&gt;at com.firstrain.web.PasswordHandler.processPasswordResetRequest(PasswordHandler.java:60)&lt;br /&gt;at org.apache.jsp.no_005fsession_jsp._jspService(no_005fsession_jsp.java:109)&lt;br /&gt;at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)&lt;br /&gt;at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)&lt;br /&gt;at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)&lt;br /&gt;at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)&lt;br /&gt;at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)&lt;br /&gt;at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)&lt;br /&gt;at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)&lt;br /&gt;at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)&lt;br /&gt;at com.firstrain.web.AuthenticationFilter.doFilter(AuthenticationFilter.java:52)&lt;br /&gt;at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)&lt;br /&gt;at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)&lt;br /&gt;at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)&lt;br /&gt;at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)&lt;br /&gt;at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)&lt;br /&gt;at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)&lt;br /&gt;at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)&lt;br /&gt;at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)&lt;br /&gt;at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)&lt;br /&gt;at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)&lt;br /&gt;at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)&lt;br /&gt;at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)&lt;br /&gt;at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)&lt;br /&gt;at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)&lt;br /&gt;at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)&lt;br /&gt;at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)&lt;br /&gt;at java.lang.Thread.run(Thread.java:619)&lt;br /&gt;Caused by: java.net.SocketException: Software caused connection abort: socket write error&lt;br /&gt;at java.net.SocketOutputStream.socketWrite0(Native Method)&lt;br /&gt;at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)&lt;br /&gt;at java.net.SocketOutputStream.write(SocketOutputStream.java:136)&lt;br /&gt;at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)&lt;br /&gt;at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)&lt;br /&gt;at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3227)&lt;br /&gt;... 37 more&lt;br /&gt;&lt;br /&gt;pecked with this exception ... peek at solution &lt;a href="http://tech-rapids.blogspot.com/2009/02/hibernate-dropping-mysql-connections.html"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-5379930369674708077?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/5379930369674708077/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2009/08/transactionjdbctransaction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/5379930369674708077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/5379930369674708077'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/08/transactionjdbctransaction.html' title='transaction.JDBCTransaction : CommunicationsException'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-8611793908625592225</id><published>2009-08-26T10:32:00.000-07:00</published><updated>2009-08-26T10:55:43.657-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><title type='text'>Using MySQL Proxy for Server Profiling and Intercepting queries</title><content type='html'>Today I tried out an MySQL Proxy(alpha, 0.7.2), which is closer to SQL profiler in the sense of monitoring all connections and queries on the server. All we need is for the client to point to the port of the proxy (default is 4040) rather than mysql server (which is mostly 3306) directly. &lt;br /&gt;&lt;br /&gt;      MySQL Proxy is a simple program that sits between your client and MySQL server(s) that can monitor, analyze or transform their communication. Its flexibility allows for a wide variety of uses, including load balancing; failover; query analysis; query filtering and modification; and many more&lt;br /&gt;MySQL Proxy is compatible with MySQL 5.0.x or later.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&gt;&gt; Links&lt;/strong&gt;&lt;br /&gt;Download. &lt;a href="http://dev.mysql.com/downloads/mysql-proxy/index.html"&gt;http://dev.mysql.com/downloads/mysql-proxy/index.html&lt;/a&gt;&lt;br /&gt;Documentation : &lt;br /&gt;    &lt;a href="http://dev.mysql.com/doc/refman/5.1/en/mysql-proxy.html"&gt;http://dev.mysql.com/doc/refman/5.1/en/mysql-proxy.html&lt;/a&gt; &lt;br /&gt;    &lt;a href="http://forge.mysql.com/wiki/MySQL_Proxy"&gt;http://forge.mysql.com/wiki/MySQL_Proxy&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Supported Platforms&lt;/strong&gt;&lt;br /&gt;      MySQL Proxy is currently available as a pre-compiled binary for the following platforms:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Linux (including RedHat, Fedora, Debian, SuSE) and derivatives.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Mac OS X&lt;/li&gt;&lt;br /&gt;&lt;li&gt;FreeBSD&lt;/li&gt;&lt;br /&gt;&lt;li&gt;IBM AIX&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Sun Solaris&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Microsoft Windows (including Microsoft Windows XP, and Microsoft Windows Server 2003)&lt;br/&gt; &lt;br /&gt;You must have the .NET Framework 1.1 or higher installed&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;       &lt;br /&gt;       MySQL Proxy is provided as a standalone, statically linked binary. You do not need to have MySQL or Lua installed (Lua is the embedded scripting language for proxy scripts)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Installing MySQL Proxy&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;      Simply download the binary package and extract to a desired location on your machine.&lt;br /&gt;      For more details on available downloads and installation instructions refer to &lt;a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-proxy-install.html"&gt;http://dev.mysql.com/doc/refman/5.0/en/mysql-proxy-install.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;MySQL Proxy Scipting&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;      LUA is the scripting language for mySQL proxy. You can generate .lua script files to manipulate and work with queries and results that are passed to or retrieved from MySQL server. The primary interaction between MySQL Proxy and the server is provided by defining one or more functions through an Lua script.&lt;br /&gt;There are a number of supported functions, according to different events and operations in the communication sequence between a client and one or more backend MySQL servers. Some of the functions are&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;connect_server() — this function is called each time a connection is made to MySQL Proxy from a client. You can use this function during load-balancing to intercept the original connection and decide which server the client should ultimately be attached to.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;read_handshake() — this function is called when the initial handshake information is returned by the server. You can capture the handshake information returned and provide additional checks before the authorization exchange takes place.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;read_auth() — this function is called when the authorization packet (user name, password, default database) are submitted by the client to the server for authentication.&lt;/li&gt; &lt;br /&gt;&lt;li&gt;read_auth_result() — this function is called when the server returns an authorization packet to the client indicating whether the authorization succeeded.&lt;/li&gt; &lt;br /&gt;&lt;li&gt;read_query() — this function is called each time a query is sent by the client to the server. You can use this to edit and manipulate the original query, including adding new queries before and after the original statement. You can also use this function to return information directly to the client, bypassing the server, which can be useful to filter unwanted queries or queries that exceed known limits.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;read_query_result() — this function is called each time a result is returned from the server, providing you have manually injected queries into the query queue. If you have not explicitly inject queries within the read_query() function then this function is not triggered. You can use this to edit the result set, or to remove or filter the result sets generated from additional queries&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;You will get some sample .lua scripts under &lt;em&gt;{install location}&lt;/em&gt;/share&lt;br /&gt;&lt;br /&gt;Below is a sample script example to get the query time for each injected query we send to server (save it to .lua file extension to use it)&lt;br /&gt;&lt;br /&gt;-- * start-time: when we call proxy.queries:append()&lt;br /&gt;-- * end-time:   when we received the full result-set &lt;br /&gt;-- @param packet the mysql-packet sent by the client&lt;br /&gt;-- @return &lt;br /&gt;--   * proxy.PROXY_SEND_QUERY to send the queries from the proxy.queries queue&lt;br /&gt;function read_query( packet )&lt;br /&gt; if packet:byte() == proxy.COM_QUERY then&lt;br /&gt;  print("we got a normal query: " .. packet:sub(2))&lt;br /&gt;  proxy.queries:append(1, packet )&lt;br /&gt;  return proxy.PROXY_SEND_QUERY&lt;br /&gt; end&lt;br /&gt;end&lt;br /&gt;-- read_query_result() is called when we receive a query result &lt;br /&gt;-- from the server&lt;br /&gt;-- inj.query_time is the query-time in micro-seconds&lt;br /&gt;-- @return &lt;br /&gt;--   * nothing or proxy.PROXY_SEND_RESULT to pass the result-set to the client&lt;br /&gt;function read_query_result(inj)&lt;br /&gt; print("qt|rt: " .. (inj.query_time / 1000) .. "|" .. (inj.response_time / 1000) ..  &lt;br /&gt;"ms: " .. inj.query:sub(2))&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;For more details on scripting refer to http://dev.mysql.com/doc/refman/5.0/en/mysql-proxy-scripting.html&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Starting With MySQL Proxy&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The default port of MySQL Proxy is 4040. You can start using MySQL Proxy in following simple steps&lt;br /&gt;&lt;br /&gt;      1. Browse to the installation directory of MySQL Proxy&lt;br /&gt;      2. Have the .lua scripts in place at some accessible location&lt;br /&gt;      3. Through command prompt run the proxy&lt;br /&gt;              a. Peeking into available functions&lt;br /&gt;                 &gt; mysql-proxy.exe –help&lt;br /&gt;                   {Lists all the available options}&lt;br /&gt;              b. Starting the proxy&lt;br /&gt;                 &gt; mysql-proxy.exe --proxy-backend-addresses=localhost --proxy-lua- script=scripts/test.lua --log-level=debug --log-file=log/results.log&lt;br /&gt;              c. To start using connect to the MySQL Server on Proxy’s port i.e 4040&lt;br /&gt;                 &gt; mysql -u root -h localhost -P 4040 –p&lt;br /&gt;                 Enter Password:&lt;br /&gt;                 mysql&gt; use mysql;&lt;br /&gt;&lt;br /&gt;Voila as you query you would see the results in your log file&lt;br /&gt;&lt;br /&gt;Some excerpts from the results.log fiel&lt;br /&gt;we got a normal query: select @@version_comment limit 1&lt;br /&gt;qt|rt: 0|0ms: select @@version_comment limit 1&lt;br /&gt;we got a normal query: SELECT DATABASE()&lt;br /&gt;qt|rt: 0|0ms: SELECT DATABASE()&lt;br /&gt;we got a normal query: SELECT DATABASE()&lt;br /&gt;qt|rt: 0|0ms: SELECT DATABASE()&lt;br /&gt;we got a normal query: select * from users limit 1&lt;br /&gt;qt|rt: 0|0ms: select * from users limit 1&lt;br /&gt;qt means query time until first bytes. rt means the query time until the last bytes.&lt;br /&gt;&lt;br /&gt;      You can also connect to MySQL server via this proxy from your applications too, have in place right set of .lua scripts to have all the monitoring at your doorsteps. &lt;br /&gt;      For example an excerpt from the persistence.xml of my JPA application&lt;br /&gt;      &lt;property name="hibernate.connection.url" value="jdbc:mysql://localhost:4040/mysql"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Warning:&lt;/strong&gt; MySQL Proxy is currently an Alpha release and should not be used within production environments&lt;br /&gt;&lt;br /&gt;Happy Querying!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-8611793908625592225?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/8611793908625592225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2009/08/using-mysql-proxy-for-server-profiling.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/8611793908625592225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/8611793908625592225'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/08/using-mysql-proxy-for-server-profiling.html' title='Using MySQL Proxy for Server Profiling and Intercepting queries'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-3283696167088001424</id><published>2009-08-25T21:26:00.000-07:00</published><updated>2009-08-25T21:37:47.423-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><title type='text'>Using MySQL User variables with Connection pooling</title><content type='html'>The point : MySQL user variables are connection specific. Period.&lt;br /&gt;http://dev.mysql.com/doc/refman/5.1/en/user-variables.html&lt;br /&gt;&lt;br /&gt;If your application is opening and closing a connection in the most simplest of fashion then you need not worry and you may use user defined variables as and when you please.&lt;br /&gt;&lt;br /&gt;Come connection pooling and whole scenario is different. &lt;br /&gt;In MySQL user-defined variables are connection-specific. You can store a value in a user-defined variable and then refer to it later. This enables you to pass values from one statement to another.&lt;br /&gt;&lt;br /&gt;Now, when we use Hibernate/JPA or your custom db layer (with connection pooling) the underlying connection is not actually closed, it's committed &amp; returned back to connection pool. As a result of which user defined variables once initialized will always be accessible and retain their previous value till the connection is active i.e. until application is shutdown or pool exhausts.&lt;br /&gt;&lt;br /&gt;If you happen to use basic JDBC infrastructure (java.sql.*) wherein you could&lt;br /&gt;explicitly close existing connection &amp; open a new one, the variable would have&lt;br /&gt;lost it's scope and reset for next time use.&lt;br /&gt;&lt;br /&gt;So better to initializing a user defined variables in MySQL with NULL before using them any further. Unlike MSSQL it is not necessary to initialize a user defined variable, so it is always a matter of practice (good or bad).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-3283696167088001424?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/3283696167088001424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2009/08/using-mysql-user-variables-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/3283696167088001424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/3283696167088001424'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/08/using-mysql-user-variables-with.html' title='Using MySQL User variables with Connection pooling'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-3553128266705703978</id><published>2009-05-26T21:41:00.000-07:00</published><updated>2009-05-26T21:52:30.368-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Exception'/><title type='text'>java.lang.IllegalStateException: getOutputStream()</title><content type='html'>---------&lt;br /&gt;Exception Trace&lt;br /&gt;---------&lt;br /&gt;&lt;br /&gt;java.lang.IllegalStateException: getOutputStream() has already been called for this response&lt;br /&gt; org.apache.catalina.connector.Response.getWriter(Response.java:596)&lt;br /&gt; org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:186)&lt;br /&gt; org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:124)&lt;br /&gt; org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:117)&lt;br /&gt; org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:191)&lt;br /&gt; org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:115)&lt;br /&gt; org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)&lt;br /&gt; org.apache.jsp.SignalStreams_002dWebVolume_jsp._jspService(org.apache.jsp.SignalStreams_002dWebVolume_jsp:1008)&lt;br /&gt; org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)&lt;br /&gt; javax.servlet.http.HttpServlet.service(HttpServlet.java:802)&lt;br /&gt; org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)&lt;br /&gt; org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)&lt;br /&gt; org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)&lt;br /&gt; javax.servlet.http.HttpServlet.service(HttpServlet.java:802)&lt;br /&gt;&lt;br /&gt;--------&lt;br /&gt;Solution&lt;br /&gt;--------&lt;br /&gt;&lt;br /&gt;Close the outputstream&lt;br /&gt;&lt;br /&gt;--------&lt;br /&gt;Sample&lt;br /&gt;--------&lt;br /&gt;I faced this problem while providing a excel file download functionality. It so happens that your first request might (if there has been a server restart) go right but in every subsequent requests this exception will occur. The most straight forward solution is to ensure that the output stream accessed has been closed properly.&lt;br /&gt;&lt;br /&gt;an excerpt from a jsp ....&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ServletOutputStream outs = null;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;   ServletOutputStream outs = response.getOutputStream();&lt;br /&gt;   response.setContentType("text/html");&lt;br /&gt;   response.setHeader("Content-Disposition", &lt;br /&gt;                      "attachment; filename=\"myfile.xls\"");&lt;br /&gt;&lt;br /&gt;   ... some code&lt;br /&gt;   ... more functionality code &lt;br /&gt;   &lt;br /&gt;   // Here we are trying to write file bytes to Outputstream&lt;br /&gt;   InputStream is = new FileInputStream("C:/myfile.xlsx");&lt;br /&gt;    &lt;br /&gt;   int bit = 256;&lt;br /&gt;   int i = 0;&lt;br /&gt;&lt;br /&gt;   while ((bit) &gt;= 0) {&lt;br /&gt;     bit = is.read();&lt;br /&gt;     outs.write(bit);&lt;br /&gt;   }&lt;br /&gt;   if(is!=null)&lt;br /&gt;   {&lt;br /&gt;     is.close();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;catch(Exception e)&lt;br /&gt;{}&lt;br /&gt;finally{ &lt;br /&gt;  if(outs != null) outs.close();&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-3553128266705703978?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/3553128266705703978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2009/05/javalangillegalstateexception.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/3553128266705703978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/3553128266705703978'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/05/javalangillegalstateexception.html' title='java.lang.IllegalStateException: getOutputStream()'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-3172282350431922579</id><published>2009-03-28T11:01:00.000-07:00</published><updated>2009-04-26T00:46:04.830-07:00</updated><title type='text'>Design Patterns</title><content type='html'>&lt;span style="font-family:georgia;"&gt;For long I had thought of Design Patterns as some kind of new technology which would magically make your project state-of-the-art, something high level and too much complicated to understand. One fine day I made the courage of dwelling deep into it, searched some good links and got hold of a few books. The realization was startling and I looked like a fool to myself.&lt;br /&gt;What I learned after going through some of the design patterns (java, j2ee etc)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:georgia;"&gt;&lt;ul&gt;&lt;li&gt;&lt;br /&gt;It is right-in-your-face same old techniques to write effective, maintainable, scalable programs. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;Something you probably have already been doing for ages and now have a catalog to see which pattern you are following in developing pragmatic software applications. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;A collection of tested and proved solutions for most common design problems&lt;br /&gt;Not a fad anymore… as most of the industry is ga-ga over Design Patterns it should now be a big part of your skill set. &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;After catching hold of a good Design Pattern book, I made my way to the various projects that I had ever worked on, surprisingly or not so surprisingly I found that there were many Patterns/practices which I had already been following (though I did identify some space for improvement(s) ).&lt;br /&gt;Now as I sit down to share my experience and possibly encouragement to use Design Patterns for all those fearless programmers, all I plan to do is brief a highlight into it and provide some good references (links, book etc). I won’t be dwelling deep into the subject (I am still fearful) as much theory and details have been written by various experts.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The big question: What are design patterns and where do they come from?&lt;/b&gt;&lt;br /&gt;“A design pattern in architecture and computer science is a formal way of documenting a solution to a design problem in a particular field of expertise. The idea was introduced by the architect Christopher Alexander in the field of architecture, and has been adapted for various other disciplines, including computer science.”&lt;br /&gt;An excerpt from wikipedia definition of &lt;a href="http://en.wikipedia.org/wiki/Design_Patterns"&gt;&lt;span style="font-family:georgia;"&gt;Design Patterns&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Design patterns have their roots from Christopher Alexander, a civil engineer who talked about his experience in solving design issues related to planning buildings and towns. Later on the idea was published in form of book for software professionals "Design Patterns: Elements of Reusable Object-Oriented Software" 1995 by Eric Gamma, Richard Helm, Ralph Johnson, and John Vlissides also known as GoF book or simply GoF.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Which technology/software do they belong to?&lt;/b&gt;&lt;br /&gt;The answer is not technology or software but rather domains or fields. Design Patterns apply to all fields, domains be it Computer Science, Housing, teaching, Healthcare et al. These are object of reusable solutions based on past experience or success/failure, time-tested and applicable everywhere. Though due to my limited knowledge I will be focusing on the ones for Object Oriented Software Development.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;A sneak peek:&lt;/b&gt;&lt;br /&gt;Describing Design Patterns&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Pattern Name:&lt;/b&gt; It is a bookmark to identify a particular design problem, related solution(s) and consequences of using it. It is a part of design vocabulary.&lt;br /&gt;&lt;b&gt;Intent:&lt;/b&gt; Describes what the pattern does, what is its intent, what particular design problem it addresses.&lt;br /&gt;&lt;b&gt;Also Known As:&lt;/b&gt; all aliases for the pattern&lt;br /&gt;&lt;b&gt;Motivation:&lt;/b&gt; Provides a solution to the problem with some examples and scenarios as to how it solves the problem. Gives a abstract description of the design patter.&lt;br /&gt;&lt;b&gt;Applicability:&lt;/b&gt; Situations and Scenarios where the pattern can be applied, bad designs that the pattern can help solve.&lt;br /&gt;&lt;b&gt;Structure:&lt;/b&gt; Diagramatic/Graphical representation of classes which depict the pattern.&lt;br /&gt;&lt;b&gt;Participants:&lt;/b&gt; Classes and objects that participate in the design pattern and their responsibilities.&lt;br /&gt;&lt;b&gt;Collaborations:&lt;/b&gt; How the classes and objects interact to perform their responsibilities.&lt;br /&gt;&lt;b&gt;Consequences:&lt;/b&gt; Benefits and trade-offs that come with using a pattern.&lt;br /&gt;&lt;b&gt;Implementation:&lt;/b&gt; What pitfalls, hints or techniques you should be aware of when implementing a particular pattern.&lt;br /&gt;&lt;br /&gt;Mainly there are 23 patterns that have been described in the GoF book and subdivided into 3 categories wiz Creational, Structural and Behavioral.&lt;br /&gt;&lt;br /&gt;Some well known Books on Design Patterns&lt;br /&gt;&lt;br /&gt;Design Patterns – Elements of Reusable Object-Oriented Software&lt;br /&gt;(Eric Gamma, Richard Helm, Ralph Johnson, John Vlissides)&lt;br /&gt;Pearson Education&lt;br /&gt;&lt;br /&gt;HeadFirst Design Patterns&lt;br /&gt;&lt;br /&gt;Applied JAVA Patterns&lt;br /&gt;Stephen Stelting, Olav Maassen&lt;br /&gt;Prentice Hall&lt;br /&gt;&lt;br /&gt;Design Patterns Java Companion&lt;br /&gt;James W. Cooper&lt;br /&gt;Free Download &lt;/span&gt;&lt;a href="http://www.patterndepot.com/put/8/JavaPatterns.htm"&gt;&lt;span style="font-family:georgia;"&gt;http://www.patterndepot.com/put/8/JavaPatterns.htm&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;&lt;/span&gt;&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/548519990128655859-3172282350431922579?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/3172282350431922579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2009/03/design-patterns.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/3172282350431922579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/3172282350431922579'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/03/design-patterns.html' title='Design Patterns'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-6394817126817894141</id><published>2009-02-03T11:10:00.000-08:00</published><updated>2009-10-07T00:29:31.055-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><title type='text'>Hibernate Dropping MySQL Connections</title><content type='html'>&lt;p&gt;A typical problem that occurs in production environment is if your application is not used/access or no db hits are made for a long time (usually more than 8 hours for MySQL) then the underlying conection gets closed. I had such a harrowing experience with my application using Hibernate and MySQL Server. My clients used to complain that once they returned to use the application after a large gap like in the morning after last accessing it in evening or night, the application did not responded, logs told that it got busted. Following was the exception recorded from logs.&lt;/p&gt;&lt;p&gt;*******************&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;[ERROR] [2009-02-03 10:36:15,737] [http-8080-1] [util.JDBCExceptionReporter] - [No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;** &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;BEGIN NESTED EXCEPTION **com.mysql.jdbc.CommunicationsExceptionMESSAGE: Communications link failure......&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;*******************&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The problem was MySQL automatically times out, and closes unused connections after 8 hours. Hibernate does not appropriately test/refreshes its connection pool when connections go stale.This problem was resolved by appropriately using a Connection Pooling mechanism overriding the Hibernate's default which can ping the MySQL Server after specific time so as to maintain a connection state with db.There were several mechanism available for Connection Pooling from which one can choose like dbcp, c3p0 or proxool. After doing some hits on the www, I decided to go for c3p0 as it seems the de-facto for mysql.The below property should be placed inside your persistence.xml or hibernate.cfg.xml after initializing Hibernate default properties.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;lt;!-- &lt;/p&gt;&lt;p&gt;acquire_increment : no. of conn. at a time c3p0 tries to acquire when pool is exhausted. min_size : min/max no. of Conn. a pool will maintain at any given time&lt;/p&gt;&lt;p&gt;timeout : no. of Seconds Conn. can remain pooled but unused before being discarded. Zero means idle connections never expire&lt;/p&gt;&lt;p&gt;idle_test_period : c3p0 will test all idle, pooled but unchecked-out connections preferredTestQuery : Defines the query that will be executed for all connection tests&lt;/p&gt;&lt;p&gt;--&amp;gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&amp;lt;!-- if using hibernate 3 (specifically 3.3.1 or above) --&amp;gt;&lt;br /&gt;&amp;lt;property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/&amp;gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&amp;lt;property name="hibernate.c3p0.acquire_increment" value="5" /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;property name="hibernate.c3p0.min_size" value="5"/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;property name="hibernate.c3p0.max_size" value="15"/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;property name="hibernate.c3p0.timeout" value="28800"/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;property name="hibernate.c3p0.idle_test_period" value="14400"/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;property name="hibernate.c3p0.preferredTestQuery" value="select 1;" /&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_QSuVlaAgXAc/SYiQx81YVtI/AAAAAAAAAEs/wvuCp5pqplw/s1600-h/untitled.bmp"&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_QSuVlaAgXAc/SYiQx81YVtI/AAAAAAAAAEs/wvuCp5pqplw/s1600-h/untitled.bmp"&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For testing the above settings try below steps&lt;br /&gt;&lt;br /&gt;Reproducing the problem&lt;br /&gt;-------------------------&lt;br /&gt;1. set property wait_timeout = 60 (1 minute) under My.ini file of MySQL, and restart your MySQL Server&lt;/p&gt;&lt;p&gt;2. Accessed your underlying application and leave for about 2-3 minutes (more than the timeout period).&lt;/p&gt;&lt;p&gt;3. Again access the application, below exception should be recorded in logs[ERROR] ...[No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error** BEGIN NESTED EXCEPTION **com.mysql.jdbc.CommunicationsExceptionMESSAGE: Communications link failureLast packet sent to the server was 63 ms ago.STACKTRACE:com.mysql.jdbc.CommunicationsException: Communications link failure Last packet sent to the server was 63 ms ago.atcom.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985)...&lt;/p&gt;&lt;p&gt;Fixing the problem&lt;/p&gt;&lt;p&gt;-------------------------&lt;/p&gt;&lt;p&gt;1. Add above c3p0 settings under persistence.xml or hibernate.cfg.xml in your application and restart it.&lt;/p&gt;&lt;p&gt;2. wait_timeout = 60 (1 minute) still applicable for MySQL&lt;/p&gt;&lt;p&gt;3. Access the application and leave for about 4-5 minutes (more than the timeout period) and even more than previous.&lt;/p&gt;&lt;p&gt;4. Again access the application, application should run fine and no connection type of exception will be recorded in logs. (unless untill you tried hard to write a really Buggy code)&lt;/p&gt;&lt;p&gt;5. removed the wait_timeout=60 value from My.ini and restart MySQL, default value for wait_timeout in MySQL is 8 hours&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Another quick fix solution set your MySQL Server wait_timeout to some large value as I did to :&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;wait_timeout=2592000&lt;/strong&gt; (seconds) which is quivalent to 30 days&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Hope this post helps anybody in distress. Do post your comments if it helped you.&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/548519990128655859-6394817126817894141?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/6394817126817894141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2009/02/hibernate-dropping-mysql-connections.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/6394817126817894141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/6394817126817894141'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2009/02/hibernate-dropping-mysql-connections.html' title='Hibernate Dropping MySQL Connections'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-66380125991240639</id><published>2007-09-27T08:11:00.000-07:00</published><updated>2009-08-25T21:40:16.738-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Struts'/><title type='text'>Struts2 - Part I : An Introduction</title><content type='html'>&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;u&gt;&lt;strong&gt;About&lt;/strong&gt;&lt;/u&gt;&lt;br /&gt;Apache Struts 2 was originally known as WebWork 2. After working independently for several years, the WebWork and Struts communities joined forces to create Struts 2.&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family:georgia;"&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Platform Requirements &lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;Servlet API 2.4&lt;br /&gt;JSP API 2.0&lt;br /&gt;Java 5&lt;br /&gt;&lt;span style="font-size:85%;"&gt;An alternate set of JARs for Java 4 are also available.&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;a href="http://struts.apache.org/2.x/struts2-core/dependencies.html"&gt;&lt;span style="font-size:85%;"&gt;Struts 2 Dependencies&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family:georgia;"&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family:georgia;"&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family:georgia;"&gt;Struts 2 Vs Struts 1.x&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;Top 10 distinctions : &lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;strong&gt;1. Servlet Dependency:&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Struts 1 :&lt;/em&gt; Actions have dependencies on the servlet API since the HttpServletRequest and HttpServletResponse objects are passed to the execute method when an Action is invoked but &lt;em&gt;Struts 2 :&lt;/em&gt; Actions are not container dependent because they are made simple POJOs. &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;Actions can access the original request and response, if required. However, other architectural elements reduce or eliminate the need to access the HttpServetRequest or HttpServletResponse directly.&lt;br /&gt;&lt;strong&gt;2. Action classes&lt;br /&gt;&lt;/strong&gt;Programming the abstract classes instead of interfaces is one of design issues of struts1 framework that has been resolved in the struts 2 framework. &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 1 :&lt;/em&gt; Action classes needs to extend framework dependent abstract base class.&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 2 :&lt;/em&gt; Action class may or may not implement interfaces to enable optional and custom services. Struts 2 provides a base ActionSupport class to implement commonly used interfaces. Albeit, the Action interface is not required. Any POJO object with a execute signature can be used as an Struts 2 Action object.&lt;br /&gt;&lt;strong&gt;3. Validation&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;Struts 1 and Struts 2 both supports the manual validation via a validate method.&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 1:&lt;/em&gt; Uses validate method on the ActionForm, or validates through an extension to the Commons Validator. &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 2:&lt;/em&gt; Supports manual validation via the validate method and the XWork Validation framework. The Xwork Validation Framework supports chaining validation into sub-properties using the validations defined for the properties class type and the validation context.&lt;br /&gt;&lt;strong&gt;4. Threading Model&lt;br /&gt;&lt;/strong&gt;&lt;em&gt;Struts 1:&lt;/em&gt; Action resources must be thread-safe or synchronized. So Actions are singletons and thread-safe, there should only be one instance of a class to handle all requests for that Action. The singleton strategy places restrictions on what can be done with Struts 1 Actions and requires extra care to develop. &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 2:&lt;/em&gt; Action objects are instantiated for each request, so there are no thread-safety issues. (In practice, servlet containers generate many throw-away objects per request, and one more object does not impose a performance penalty or impact garbage collection.)&lt;br /&gt;&lt;strong&gt;5. Testability&lt;br /&gt;&lt;/strong&gt;&lt;em&gt;Struts 1:&lt;/em&gt; Testing applications are a bit complex. A major hurdle to test Struts 1 Actions is that the execute method because it exposes the Servlet API. A third-party extension, Struts TestCase, offers a set of mock object for Struts 1. &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 2:&lt;/em&gt; Actions can be tested by instantiating the Action, setting properties, and invoking methods. Dependency Injection support also makes testing simpler. Actions in struts2 are simple POJOs and are framework independent, hence testability is quite easy in struts2.&lt;br /&gt;&lt;strong&gt;6. Harvesting Input&lt;br /&gt;&lt;/strong&gt;&lt;em&gt;Struts 1:&lt;/em&gt; Uses an ActionForm object to capture input. And all ActionForms needs to extend a framework dependent base class. JavaBeans cannot be used as ActionForms, so the developers have to create redundant classes to capture input. &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 2:&lt;/em&gt; Uses Action properties (as input properties independent of underlying framework) that eliminates the need for a second input object, hence reduces redundancy. Additionally in struts2, Action properties can be accessed from the web page via the taglibs. Struts 2 also supports the ActionForm pattern, as well as POJO form objects and POJO Actions. Even rich object types, including business or domain objects, can be used as input/output objects.&lt;br /&gt;&lt;strong&gt;7. Expression Language&lt;br /&gt;&lt;/strong&gt;&lt;em&gt;Struts 1:&lt;/em&gt; Integrates with JSTL, so it uses the JSTL-EL. The struts1 EL has basic object graph traversal, but relatively weak collection and indexed property support. &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 2:&lt;/em&gt; Also uses JSTL, however it supports a more powerful and flexible expression language called "Object Graph Notation Language" (OGNL).&lt;br /&gt;&lt;strong&gt;8. Binding values into views&lt;br /&gt;&lt;/strong&gt;&lt;em&gt;Struts 1: &lt;/em&gt;In the view section, uses the standard JSP mechanism to bind objects(processed from the model section) into the page context to access . &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 2:&lt;/em&gt; Uses a "ValueStack" technology so that the taglibs can access values without coupling your view to the object type it is rendering. The ValueStack strategy allows the reuse of views across a range of types which may have the same property name but different property types.&lt;br /&gt;&lt;strong&gt;9. Type Conversion&lt;br /&gt;&lt;/strong&gt;&lt;em&gt;Struts 1:&lt;/em&gt; ActionForm properties are all Strings. Struts 1 uses Commons-Beanutils for type conversion. These type converters are per-class, and not configurable per instance. &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 2:&lt;/em&gt; uses OGNL for type conversion. The framework includes converters for basic and common object types and primitives.&lt;br /&gt;&lt;strong&gt;10. Control Of Action Execution&lt;br /&gt;&lt;/strong&gt;&lt;em&gt;Struts 1:&lt;/em&gt; Supports separate Request Processors (lifecycles) for each module, but all the Actions in a module must share the same lifecycle. &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;em&gt;Struts 2:&lt;/em&gt; Supports creating different lifecycles on a per Action basis via Interceptor Stacks. Custom stacks can be created and used with different Actions, as needed.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="#"&gt;&lt;img id="BLOGGER_PHOTO_ID_5114951938375594082" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://bp3.blogger.com/_QSuVlaAgXAc/Rvv1sBISsGI/AAAAAAAAACw/7jzofIYM_AE/s320/Struts1-2.bmp" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&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/548519990128655859-66380125991240639?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/66380125991240639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2007/09/struts2-part-i-introduction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/66380125991240639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/66380125991240639'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2007/09/struts2-part-i-introduction.html' title='Struts2 - Part I : An Introduction'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp3.blogger.com/_QSuVlaAgXAc/Rvv1sBISsGI/AAAAAAAAACw/7jzofIYM_AE/s72-c/Struts1-2.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-548519990128655859.post-8900207038148236256</id><published>2007-09-27T08:10:00.000-07:00</published><updated>2009-08-25T21:40:37.297-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Struts'/><title type='text'>Struts2 - Part II : Moving ahead</title><content type='html'>&lt;span style="font-family:georgia;"&gt;&lt;strong&gt;Configuration :&lt;/strong&gt; &lt;br /&gt;A typical web.xml file of Struts 1 &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;    &amp;lt;servlet&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;servlet-name&amp;gt;action&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;servlet-class&amp;gt;org.apache.struts.action.ActionServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;init-param&amp;gt;&lt;br /&gt;&lt;br /&gt;     &amp;lt;param-name&amp;gt;config&amp;lt;/param-name&amp;gt;&lt;br /&gt;&lt;br /&gt;     &amp;lt;param-value&amp;gt;/WEB-INF/struts-config.xml&amp;lt;/param-value&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;/init-param&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;load-on-startup&amp;gt;2&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;/servlet&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;servlet-mapping&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;servlet-name&amp;gt;action&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;url-pattern&amp;gt;*.do&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;/servlet-mapping&amp;gt;&lt;/pre&gt;In Struts 2 the most significant change is that the dispatcher has been changed from a servlet to a servlet filter.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;    &amp;lt;filter&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;filter-name&amp;gt;webwork&amp;lt;/filter-name&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;filter-class&amp;gt;&lt;br /&gt;&lt;br /&gt;     org.apache.struts.action2.dispatcher.FilterDispatcher&lt;br /&gt;&lt;br /&gt; &amp;lt;/filter-class&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;/filter&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;filter-mapping&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;filter-name&amp;gt;webwork&amp;lt;/filter-name&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;/filter-mapping&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;filter-mapping&gt;&lt;url-pattern&gt;&lt;filter-mapping&gt;&lt;filter-mapping&gt;&lt;/FILTER-MAPPING&gt;&lt;/FILTER-MAPPING&gt;&lt;/URL-PATTERN&gt;&lt;/FILTER-MAPPING&gt;&lt;/pre&gt;For Struts, the servlet configuration provides an init-param tag that defines the names of the files used to configure Struts. Struts2 does not have such a configuration parameter. Instead, the default configuration file for Struts2 has the name "struts.xml" and needs to be on the classpath of the web application.&lt;br /&gt;&lt;br /&gt;A Struts 2 : Struts.xml file&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&amp;lt;struts&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;include file="struts-default.xml"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;constant name="struts.enable.DynamicMethodInvocation" value="false" /&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;constant name="struts.devMode" value="true" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;!-- Add packages here --&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;package name="default" extends="struts-default"&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;action name="home" class="com.dev.mystruts2.MyAction"&amp;gt;&lt;br /&gt;&lt;br /&gt;   &amp;lt;result&amp;gt;/WEB-INF/pages/helloWord.jsp&amp;lt;/result&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;/action&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;/package&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/struts&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Struts 1 Action Class :&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class MyAction extends Action {  &lt;br /&gt; public ActionForward execute(ActionMapping mapping,&lt;br /&gt;         ActionForm form,&lt;br /&gt;         HttpServletRequest request,&lt;br /&gt;         HttpServletResponse response)       &lt;br /&gt;  throws Exception {      &lt;br /&gt;  // do the work      &lt;br /&gt;  return (mapping.findForward("success"));  &lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Struts 2 Action :&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class MyAction { &lt;br /&gt; public String execute() throws Exception {      &lt;br /&gt; // do the work      &lt;br /&gt; return "success"; &lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The first thing you may have noticed is that the action doesn't extend any classes or interfaces. In fact, it goes further than this. By convention, the method invoked in the processing of an action is the "execute" method - but it doesn't have to be. Any method that follows the method signature public String methodName() can be invoked through configuration.&lt;br /&gt;&lt;br /&gt;Next, the return object is a String. If you don't like the idea of string literals in your code, there is a helper interface Action available that provides the common results of "success", "none", "error", "input" and "login" as constants.&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&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/548519990128655859-8900207038148236256?l=tech-rapids.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-rapids.blogspot.com/feeds/8900207038148236256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tech-rapids.blogspot.com/2007/09/struts2-part-ii-moving-ahead.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/8900207038148236256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/548519990128655859/posts/default/8900207038148236256'/><link rel='alternate' type='text/html' href='http://tech-rapids.blogspot.com/2007/09/struts2-part-ii-moving-ahead.html' title='Struts2 - Part II : Moving ahead'/><author><name>Shajee</name><uri>http://www.blogger.com/profile/08222340263021610184</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_QSuVlaAgXAc/S9_6zdff6TI/AAAAAAAAAOQ/knac-ciRMIs/S220/shajee.jpg'/></author><thr:total>0</thr:total></entry></feed>
