Thursday, January 10, 2013

Enable SQL logging in websphere commerce

Follow the steps to enable SQL logging in WCS
  • Log in to WAS Administrative console
  • Select Troubleshooting->logs and trace->server1->change log details levels
  • Expand element com.ibm.ejs.persistences.* & enable all Messages and traces for com.ibm.ejs.persistence.EJSDBCFinder and com.ibm.ejs.persistence.EJSJDBCPersister

Tuesday, October 9, 2012

Enabling the PC Keyboard in Android Emulator

By default the PC Keyboard is not enabled in Android Emulator and it is a pain to use the emulator keyboard. To enable the PC keyboard in emulator you can do the following steps
  • Go to the directory /.android/avd/.avd/ in my case it was C:\Documents and Settings\db2inst1\.android\avd\JellyBean.avd
  • Open the file config.ini
  • Add an entry in the file hw.keyboard=yes
  • Save the file and restart the emulator. Now the PC key board is enabled

Changing hosts file in Google Android Emulator

Now a days lots of our developers are coming with the same question as how do they change the host file in android. So I thougt that it is worth sharing the steps
  • Start Android Virtual Device(AVD) from AVD manager via checking on the check boxes "Launch from Snapshot" &"Save to Snapshot on". Otherwsie the changes you will make via following the process will be ignored and it will take the default host file entries.
  • Run Android\android-sdk-windows\platform-tools\adb remount to make the image as writable
  • Run Android\android-sdk-windows\platform-tools\adb pull /system/etc/hosts c:\android to copy the hosts file to the machine
  • After making changes to the hosts file put it back to android via running Android\android-sdk-windows\platform-tools\adb push c:\android\hosts /system/etc
  • Note that 127.0.0.1 ip will be pointing to the emulator device and 10.0.2.2 will point to the computer where emulator is installed

 

Thursday, June 16, 2011

Ways to overcome the same-origin policy browser restriction

One of my friend asked me yesterday what are the different ways of overcoming the same-orgin policy restriction in browsers. I have given the answer and thought that it might be worth sharing it..

  • The Web page request data from the Web server it originates from, and to have the Web server behave as a proxy relaying the request to the actual third-party servers. Although widely used, this technique isn't scalable
  • Use frame elements to create new areas in the current Web page, and to fetch any third-party content using GET requests. After being fetched, however, the content in the frames would be subject to the same-origin policy limitations
  • Insert a dynamic script element in the Web page, one whose source is pointing to the service URL in the other domain and gets the data in the script itself. When the script loads, it executes. It works because the same-origin policy doesn't prevent dynamic script insertions and treats the scripts as if they were loaded from the domain that provided the Web page

Showing Text Vertically Aligned In The Browser

Recently in one of the projects we did have a requirement to show the terms & conditions in a vertically aligned format while all other contents in the page has to display in horizontally aligned format.
The solution that we have found out, works well with all the IE versions from 6 onwards and all the Mozilla versions from 3.1 onwards.
The following HTML content will do the job

<head>
<style>
.notrans {
width: 300px;
border:4px solid #ff0000;
}

.trans {
width: 300px;
border:4px solid #ff0000;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
</style>
</head>
<body>
<div class="notrans">An element without translation</div>
<br /><br />
<div class="trans">An element translated horizontally by 100px</div>
</body>

Precompiling JSP Files in WCS

Expand the enterprise application archive using the following command. WAS_installdir/bin/EARExpander -ear /mytmp/WC_instance.ear -operationDir /mytmp/WC_instance.expanded.ear -operation expand -expansionFlags war

· Change the JSP Engine parameters. You want to ensure that the JSP engine will not compile any JSP files for the Stores Web module at run time. This ensures that your precompiled JSP files from the WEB-INF directory is used.

o Open /mytmp/WC_instance.expanded.ear/Stores.war/ibm-web-ext.xmi in a text editor.

o Add the following line before the line

</webappext:WebAppExtension>

< xmi:id="JSPAttribute_2" name="disableJspRuntimeCompilation"

value="true"/>>

Ensure that the xmi:id of the new line is unique within the file.

o Run the JSP batch compiler using the command WAS_installDir/bin/JspBatchCompiler -ear.path /mytmp/WC_jbweb1.expanded.ear -webmodule.name Stores.war -compileToWebInf true

o Since you disabled runtime compilation in Step 3, you must review the log to ensure that all JSP files compiled without error. If some JSP files are not compiled, correct the error and run the compilation step again

Long Name Directory Delete in Windows

Recently one of the tool have created a long directory structure in our Windows 2003 server machine. When we were trying to delete the path via explorer windows was not allowing us to do so. We have tried it through dos with rd /S option still it is not allowing us. We just went inside the leaf directory and try to delete all the files in the leaf directory, we got a message saying that "the file name or extension is too long". We have googled and find out the command to remove the directory that is too long(basically bigger than MAX_PATH=260). The solution is to give a fully qualified file name via giving \\?\fullpath. So actually if you want to remove a directory named C:\ab which contain a subfolder tree that is having a path that violate the above condition you could give the following command
rd /S \\?\C:\ab