Wednesday, December 22, 2010

MultiLanguage enabled JSPs

Step-1 : Load the jstl and fmt tag libraries in your jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

Step-2 : Check the locale
<c:if test="${param.locale == 'de_DE'}">
   <fmt:setLocale value="de_DE" />
</c:if>

Step-3 : Based on the locale, load appropriate bundle. Here if the locale is de_DE then message_de_DE.properties will be loaded.
<fmt:bundle basename="message">

Step-4 : Externalize(localize) the text in jsp, to the appropriate properties file, below statement will load the text corresponding to "LblHeading" from message_de_DE.properties file.
<fmt:message key="LblHeading"/>

Thursday, October 28, 2010

Hibernate Connection


Connecting to SQL server through Hibernate
Jar required: sqljdbc.jar
Jdbc driver name: com.microsoft.sqlserver.jdbc.SQLServerDriver
Connection string: jdbc: sqlserver://:1433;DatabaseName=

Connecting to AS400 through Hibernate
Jar required: jt400.jar
Jdbc driver name: com.ibm.as400.access.AS400JDBCDriver
Connection string: jdbc:as400:///;transaction isolation=none

Connecting to DB2 through Hibernate
Jar required: db2jcc.jar
Jdbc driver name: com.ibm.db2.jcc.DB2Driver
Connection string: jdbc:db2://:50000/

Sunday, October 17, 2010

Software Engineering - A Recall..


                                    Best Practices of Software Engineering



Best practices are a set of commercially proven approaches to software development which, when used in combination, strike at the root causes of software development problems. They are observed to be commonly used in industry by successful organizations.

The above mentioned best practices are documented in The Rational Unified Process – An Introduction


A model is a complete description of a system from a particular perspective.
 
Diagrams are views of a model.



  •  Use-case diagrams illustrate user interactions with the system.
  •  Class digrams illustrate logical structure.
  •  Object diagrams illustrate objects and links.
  •  State diagrams illustrate behavior
  •  Component diagrams illustrate physical structure of the software.
  •  Deployment diagrams show the mapping of software to hardware configurations
  •  Interaction diagrams ( i.e. collaboratoin and sequence diagrams) illustrate behavior
  •  Activity diagrams illustrate the flow of events in a use-case.


An architectural view is a simplified description of a system from a particular perspective or vantage point, covering particular concerns and omitting entities that are not relevant to this perspective.



                  Representing Architecture: The 4+1 View Model

Logical View – addresses the functional requirements of the system.

Implementation view
– describes the organization of static software modules in the development environment, in terms of packaging, layering and configuration management.

Process view – addresses the concurrent aspect of the system at sun-time: tasks, threads or processes, and their interactions. 

Deployment view – shows how the various executables and other run-time components are mapped onto the underlying platforms or computing nodes.


                                         Analysis Versus Design

Analysis, focus is on understanding the problem

Design, focus is on understanding the solution


Monday, September 27, 2010

Configuring TestNG in Eclipse



Installing TestNG


Installing Eclipse Plugin for TestNG

1.       Download the TestNG eclipse plugin from (http://beust.com/eclipse/)
2.       Copy the downloaded jar file into following directory structure



3.       Create the “TestNG.link” file in ‘links’ folder of Eclipse installation
4.       Edit the file to provide the path of plugin
path=C:/Eclipse - Helios/eclipse-jee-helios-win32/eclipse/ExternalPlugins/TestNG
5.       Restart the Eclipse.




Verifying Installation

1.       Open Windows -> Show Views -> Others  to see if TestNG is listed as follows

Testing ( A simple Example )


1.       Create a TestNG class. 




2.       Specify the following details.  For more details on the annotations visit the TestNG site. They are pretty much same as Junit annotations.

3.       You also need to add the ‘testng.jar’ file so that the annotations can be recognized. In order to add this to your projects classpath. Select ‘Configure Build Path -> Add Variable -> Select the TESTNG_HOME -> Extend Variable to include testng.jar’




4.       Following generated Class should now be compiled

5.       Creating a ‘Launch Configuration’

6.       In the launch configuration select the TestNG class













7.       Select ‘Run’ from the launch configuration. You should see following in the “TestNG” dialog

8.       Above steps tested a method “f()” . The test was successful because there was no error or exceptions encountered in the method “f()” .
9.       Now intentionally modify the method to throw a new RuntimeException.
10.   Run the same Launch Configuration, and see the test results as below


Sunday, August 22, 2010

Validating XML against schema - Visual Studio 2008

This section assumes that schema, is present in local system.
For validating XML through schema, you have to specify below two attributes in root element of XML document.

1. Using absolute path
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.example.com/ file://C:/schema/test/SampleOne.xsd'

2. Using relative path
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.example.com/ ./SampleOne.xsd'

Suggested Reading
http://www.wrox.com/WileyCDA/Section/Editing-XML-and-XML-Schema-in-Visual-Studio-2008.id-320326.html

Tuesday, May 11, 2010

COBOL programs for windows

Most of the enterprise code till date is still in COBOL. Understanding COBOL is a good experience, and can be an arrow in your sheath.

I used Fujitsu NetCobol for running sample COBOL programs on windows. The IDE it provides is built on eclipse platform and thus is convenient for a person already using eclipse, RAD or similar IDE..
For now running COBOL programs seems to be fun and learning... :)

Determining version of compiled class..

Came across an issue which involved determining on what version a particular file was compiled. There is one nice utility that comes with JDK, which allows to get this information from class file.

Usage:
javap -verbose

if you want to redirect output to a text file.

javap -verbose TestClass >> output.txt

Monday, February 22, 2010

Asynchronus Javascript and JSON !!!!

With ajax finding its due place in web app world, the need for faster communication with server components has manifested clearly. XML requiring large memory footprint is now frequently replaced by JSON as the medium of data communication. Since when I have been involved with JSON I am looking for some good Java-JSON binding framework. We have some good Java-XML binding frameworks (JAXB, JIBX, Castor to name a few.. ). Searching the internet following JSON binding frameworks seems to be doing what is required.
Jackson (http://jackson.codehaus.org/)
Skaringa (http://skaringa.sourceforge.net/)

If JSON-Java is there, aren't you finding yourself thinking about XML-JSON conversions. Yes you can enjoy reading and example at http://www.thomasfrank.se/xml_to_json.html
Suerly, there are other tools for the same purpose which are budding.

Particularly interesting are the tools coming up that aims to achieve what has been done with XML for a long time, i.e XSLT. Go on with some reading at the links below and you will find them interesting.
http://goessner.net/articles/jsont/ (XML: XSLT :: JSON : -----)

........

Friday, January 15, 2010

Few strange errors..

1. java.lang.classFormatError: Bad magic number at offset=0

probable cause: deploying a corrupted jar file.
When you create a jar file using command jar -cf and if by chance you forget to specify the name of jar file, then the classes are corrupted you have to recompile the classes and again create the jar file.


2. Ajax response getting cached.

On using below code I observed that servlet was hit only once, the reason being that the response is cached by IE
xmlHTTP.open("GET" ,"../servlet/MyServlet", true);
xmlHttp.send(null);
hence when using "GET" method in ajax request, (based on your requirement i.e if you do not want the browser to cache your response) set the
response.setHeader("Cache-Control", "no-cache");
in your server side code, in this case servlet.

Let this be a Technical Me !!!

Writing this blog and hoping that it grows with whatever things that I am playing with, yes of course at my workplace ;-)