Thursday, December 23, 2010

Accents becoming garbage on form submits and Character Encoding

How non-ASCII data like Accents and Apostrophes gets displayed in HTML, retrieving such data through form fields and how data gets stored in the database with correct format is handled in few place. The trick is, in all these places the encoding format should be the same, which is typically UTF-8.

Following are the locations where encoding format is defined and how its done.

Page content format:
Set the HTML file's character encoding format through HTTP headers or meta tags.
Eg: < meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />  
If this is not set browsers assume  ISO-8859-1 to be the default character encoding format.

Form submits:
GET and POST request parameter are also encoded according to the page encoding format.
This can be overridden by using the accept-charset="UTF-8" attribute in the form tag. 


Server Request Parameters:
In Servelts, JSPs and Portlets, request paramter encoding format can be set by the following statement.
request.setCharacterEncoding("UTF-8");
If this is not set the web servers assumes the default format as ISO-8859-1.
To make the things more generic, the encoding format can be set
in doFilter method of a Servlet Filter.

public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain)
   throws IOException, ServletException {
        if (request.getCharacterEncoding() == null) {
            String encoding = "UTF-8";
            if (encoding != null)
                request.setCharacterEncoding(encoding);
        }

chain.doFilter(request, response);       

//do it again, since JSPs will set it to the default       
     if (encoding != null)
        request.setCharacterEncoding(encoding);

}

One tricky point is if the form encryption type is "multipart/form-data" then each value should be
read by specifying the encoding type like below.

FileItem item = (FileItem) iter.next();
if (item.isFormField())
value = item.getString("UTF-8").trim();

The final point the data encoding format should be handled is the Database it self. This should be
set at the time the database is created. If this format is changed after creating the database, existing
data will be corrupted.


Reference : http://java.sun.com/developer/technicalArticles/Intl/HTTPCharset/

Friday, December 10, 2010

Oracle License

Oracle’s technology products are licensed using two metrics: Named User Plus (NUP) or Processor.

Named User Plus Metric:
This metric is used in environments where users can be identified and counted. Named User Plus includes both humans and non-human operated devices. A licensed Named User Plus may access the program on any instances where it is deployed, provided that the minimum on each server is met.
Named User Plus minimum is 25 Named Users Plus per Processor. Total number of Named User Plus Licenses required are  either Named User Plus for total processors or Total number of Named Users which ever is greater.

Processor Metric:
This metric is mostly used in environments where the software users cannot be easily identified or counted, such as internet-based applications.
Total Number of Licensable Processors = (number of processors) *(number of cores)*(multi-core factor)

Multi-core factor is:
0.25 for SUN's UltraSparc T1 processors
0.50 for Intel and AMD processors
0.75 for all other multi-core processors
1.00 for single-core processors

Useful commands to check the server configurations:
Number of CPUs and Cores => grep -i core /proc/cpuinfo
processor model and all other info => cat /proc/cpuinfo
Linux Version => cat /proc/version

Sunday, August 29, 2010

ProxyRequests and ProxyPass in Apache

Apache can do both forward proxying and reverse proxying.

forward proxying-
Acting as a tunnel to the internet. Users has to configure there application software (Eg. Internet Brower)  by adding the IP of the proxy server in order to access Internet.To activate forward proxying in Appache need to add the following configuration in httpd.conf file.
ProxyRequests On
When accessed through a proxy the ip of the user is not visible so users can do unauthorised activities by hiding himself. Because of this the administrator should secure the server and allow access only to authorised users.

Reverse proxying-
Acting as a web server to third party content. The server will grab content from
a third party server and send to the user as if the server it self is generating the content.To activate reverse proxying in Appache need to add the following configuration.
ProxyRequests Off #Not necessary however.
ProxyPass /path-to-content http://some-other-server.domain
There is however one glitch here. The browser headers will hold the original server
details plus the relative links in the provided content will link directly to the
original site. To avoid this need to add another configuration ProxyPassReverse
as below.
ProxyPass /path-to-content http://some-other-server.domain
ProxyPassReverse /path-to-content http://some-other-server.domain 

Serving sub directory content by the server it self-
Any sub directory of a directory path can be configured to serve contents of itself rather than serving content from the same third party server.To do this use the exclamation mark in front of the directory which needs to be blocked and serve own content.
ProxyPass /path-to-content/sub-directory !
ProxyPass /path-to-content http://some-other-server.domain
ProxyPassReverse /path-to-content http://some-other-server.domain 
 
References:
http://helpful.knobs-dials.com/index.php/Apache_URL_rewriting 
 

Sunday, July 4, 2010

Enterprise application integration the begining

The story goes back to the year 1985. It all started in one persons mind and his name is Vivek Ranadive an Electrical Engineer and an entrepreneur. He was trained as a Hardware Engineer in MIT Massachusetts Institute of Technology and that made him to think about creating a so called "software bus" which allows various softwares to plug in and communicate through a single interface just like the computer hardware bus and interface cards do. He applied this theory on one of the projects which was undertaken by his company Teknekron and that project was to automate a stock market trading floor of "The Goldman Sachs Group, Inc.". His project became successful so is his idea the "Information Bus".


Today we have several acronyms having this same meaning.
Or putting them altogether today we call  SOA - Service Oriented Architecture.

MillenniumIT is a leading technology solutions provider in Sri Lanka who now claims to have developed the fastest trading system in the world which is based on a messaging middle ware or information bus built in house. It handles trades in 130 microseconds, compared with 250 microseconds on Nasdaq OMX, which had claimed to be the fastest based on commercial application. MillenniumIT system said to be handling up to 1m messages per second, compared with 20,000 available on TradElect another platform. Chi-X Europe operates a system capable of handling 225,000 messages per second.

References:

TIBCO
Driving the information bus
WebMethods Vs TIBCO
Where Is the Real-Time Web Message Bus
NETSCOUT - Enterprise - Financial Services
About MillenniumIT
Distributed-JMS
JMS and Spring

Sunday, June 6, 2010

Nokia X3 and Fring


I got my new Nokia X3 and was trying to setup Fring. Fring gets your favourite messenger software in your mobile. It supports Skype, Yahoo, GTalk, Twitter, MSN Live, ICQ etc. Fring version which supports X3 is a Java/j2ME application and to make it access the network a preferred access point should be setup in the mobile. If this is not done the preferred access points list is empty and the application will throw a connection Error.

This is how to add a preferred access point. Goto Menu -> Settings >Configuration settings -'> Personal Configuration settings. Then select Options-> Add new ->Access Point. You can keep the default Account Name and Access point settings. That’s it and now you can start using Fring.
Check fring @ http://www.fring.com/default.php

Wednesday, March 31, 2010

Oracle Enterprise Manager Console – Password Expired

Today I got the following message while trying to access the oracle enterprise console.
Failed to connect to database instance: ORA-28001: the password has expired (DBD ERROR: OCISessionBegin).
The log was draining the following errors.

[ApplicationServerThread-5] ERROR eml.OMSHandshake processFailure.806 - OMSHandshake failed.
java.sql.SQLException: ORA-28001: the password has expired
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:283)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:278)
at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:792)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:365)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:519)

To fix the issue
================
* Stop enterprise manager -> emctl stop dbconsole
* login to sqlplus as sysdba -> sqlplus "/as sysdba"
* reset sysman password -> alter user sysman identified by <the new password> ;
* reset dbsnmp password -> alter user dbsnmp identified by <the new password> ;
* find the emoms.properties file -> find <ORACLE_HOME> -name emoms.properties
* select the emoms.properties file in ORACLE_HOME/HOST_SID/sysman/config
* Change sysman password in emos.properties -> oracle.sysman.eml.mntr.emdRepPwd=New Password
* Change encrypted to false in emos.properties -> oracle.sysman.eml.mntr.emdRepPwdEncrypted=FALSE
* Find the targets.xml file in ORACLE_HOME/HOST_SID/sysman/emd
* Change dbsnmp password in targets.xml and set encrypted to FALSE -> <Property NAME=”password” VALUE=”<New Password>” ENCRYPTED=”FALSE”/>
* Restart the enterprise console -> emsctl start dbconsole

Oracle 11g sets password expiry by default. This is the reason behind getting the password expiry messages.
To stop this happening in the future do the following.
* Login to sqlplus as sysdba -> sqlplus "/as sysdba"
* Execute ->ALTER PROFILE DEFAULT LIMIT FAILED_LOGIN_ATTEMPTS UNLIMITED PASSWORD_LIFE_TIME UNLIMITED;

Steps to reconfigure the DB Control in case of a host name change etc.
===============================================
set oracle_sid=YourInstanceName
emctl stop dbconsole
emca -deconfig dbcontrol db
emca -repos recreate
emca -config dbcontrol db
emca -reconfig ports -DBCONTROL_HTTP_PORT 80 (This port change is optional)

References - http://www.eggwater.co.uk/wordpress/?p=4

Thursday, March 4, 2010

Fixing JAXB LinkageError in JBoss with JDK 1.6

Struggled a bit to sort out the following issue which popped while trying to deploy a web service in Jboss booted with JDK 1.6

java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/liferay_portal/jboss-tomcat-4.2.3/server/default/tmp/deploy/tmp3673jaxb-impl.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/) at com.sun.xml.bind.v2.model.impl.ModelBuilder.(ModelBuilder.java:172) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:422) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:286) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139) at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:105)

To fix this need to copy the following jars from ${JBOSS_HOME}/client to ${JBOSS_HOME}/lib/endorsed:

* jaxb-api.jar
* jboss-jaxrpc.jar
* jboss-jaxws.jar
* jboss-jaxws-ext.jar (applies to 2.0.2 +)
* jboss-saaj.jar

Also if the following error occur when invoking the service .

12:50:28,718 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
at javax.xml.soap.SOAPMessage.setProperty(SOAPMessage.java:441)
at org.jboss.ws.core.soap.SOAPMessageImpl.(SOAPMessageImpl.java:67)
...

Copy the above jars plus the following from ${JBOSS_HOME}/lib to ${JBOSS_HOME}/lib/endorsed:

*log4j-boot.jar
*jboss-common.jar
*concurrent.jar

Thursday, February 4, 2010

62nd Independence Day of Sri Lanka




A day to think like a Sri Lankan and act like a Sri Lankan despite the race, religion and colour of you and me. This time we celebrate our independence with pride after defeating the LTTE on last year. LTTE was at that time an internationally organized terrorism outfit and Sri Lanka is the first and the only nation who was able to defeat such a strong separatist terrorist organization through a war.

Evidence from the history shows division among Sri Lankans have always brought bad consequences to the country. So let’s remember the lessons learned and play our role to build our motherland.

May our nation be blessed by the Noble Triple Gem.

Some links I found interesting.

Wilbawe, Kiulegedara Mohottala, Butawe Rate Rala from Uva Rebellion
The English episode in Ceylon
Keppetipola Disawe
http://14poems.com/

Friday, January 1, 2010

Installing ASIO4ALL in my laptop

Yesterday I was struggling a bit to install ASIO4ALL driver to my laptop Pavilion dv6 with Windows Vista Home premium installed.

Note on ASIO:
ASIO Is a sound card driver which is used for processing sound through PC software while removing the low-latency of standard drivers and improving reliability for professional sound processing. ASIO4All is a generic driver which can be used with soundcards which does not have the native ASIO driver.

Installing is very easy as all you have to do is run the setup file. After installing you have to select the ASIO driver from the audio settings panel of your software.


No sound after selecting ASIO4All



There are couple of things to check.









From the advance panel select only the relevant device and the interface and disable the others. In my case I have disabled the "High Definition Audio Device" and enabled the IDT High Definition Audio CODEC and MuxedIn1 and Speaker1 interfaces.





Also the bit depth of the input and output interfaces should be set to 16bits. This can be done from Control Panel>Sound> and selecting Properties of the Interface and choosing the Advance tab.

Subscribe