jqGrid cell data disappears on clicking other cells

Bug: jqGrid cell data in a previously edited cell disappears on editing other rows. This usually occurs after a cell or row value is edited programmatically.

Reason: A cell could not reset its DOM to display mode from Edit mode.

Fix:  Fix is to restore an edited row/cell before doing further operations on its event handler functions ( like launching a new dialog to put in some processed value back to it using script).

UTF-8 encoding on J2EE

A 3 step method to apply UTF-8 encoding to J2EE applications.

1. Add the following directives to the page included in ALL jsps.

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>

This will add request headers and meta-tags to every page served which will tell the browser that the page is utf-8 encoded.

2. Add a filter at server side to encode the request body received to UTF-8. A spring UTF-8 encoder (available in org.springframework.web*.jar of spring 3 distribution) if used, will have the following changes in web.xml:

<filter>
	<filter-name>encodingFilter</filter-name>
	<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
	<init-param>
		<param-name>encoding</param-name>
		<param-value>UTF-8</param-value>
	</init-param>
</filter>
<filter-mapping>
			<filter-name>encodingFilter</filter-name>
			<url-pattern>/*</url-pattern>
</filter-mapping>

3. Tell the container that the URLs too are to be encoded in UTF-8. In tomcat, this is done by adding the attribute URIEncoding=UTF-8 to the connector tag in server.xml. Else, this can also be done by setting useBodyEncodingForURI=true in the connector tag. This will tell the connector to use the same encoding used for the request body (set to UTF-8 in the previous steps.) This will make sure that the parameters received via GET requests too are properly understood by the application.

AirRaid

An MS DOS game where you shoot opponent fighter plane and save yourself from incoming missiles 😉

Download code here.

(Note/Disclaimer : Last successful compilation of most of the programs in this category were done from 2000 to 2002.)

Update, August 2026 — this download was lost when the site went down. The source has since been salvaged from the author’s original media and is restored above. AIR_RAID.CPP (the text-mode version) compiles standalone under Turbo C++; AIRGRAPH.CPP, the graphical version, is included but depends on kjmenu.cpp, which did not survive. The 2000 binary is bundled as well.

Brikz

A simple brick game written in C++

Download code here.

(Note/Disclaimer : Last successful compilation of most of the programs in this category were done from 2000 to 2002.)

Update, August 2026 — the original source code for this program did not survive and could not be salvaged from the archives. Only the compiled MS-DOS binary from 2000 could be recovered, and that is what the link above now provides. It still runs under DOSBox.

Mines

A minesweeper game programmed in C++.

Download code here.

Update, August 2026 — this download was lost when the site went down. Neither the source code nor a compiled binary could be salvaged from the archives, so no download is available. The description is kept here for the record.

C Chess

A simple Chess program written in C. Serves as an introduction to basics of programming the game.

Download code here.

(Note/Disclaimer :Given on as is basis (written by author during high school – 1999 to 2001))

Update, August 2026 — the original source code did not survive and could not be salvaged from the archives. The link above now provides the compiled binary together with CHESS.H, the one surviving fragment of the source — the piece definitions.

Solution to Hibernate error: Unknown column ‘******’ in ‘order clause’

Bug: A above exception thrown when using hibernate.

Reason: This error occurs usually because of a misplaced “order by” clause.
If in a many to many mapping, the serial order is defined in the cross reference table, the order-by attribute should be provided in the “collection” node as below –

<bag name="projects" ... table="users_projects" inverse="true" order-by="sl_num">
  		<key column="userId"/>
  		<many-to-many column="projectId" class="Project"/>
 </bag>

On other hand, if the collection is to be sorted by a column defined in the collection member, the order-by should be provided in the many-to-many or one-to-many node, as shown below.

<bag name="projects" ... table="users_projects" inverse="true">
  		<key column="userId"/>
  		<many-to-many column="projectId" class="Project"  order-by="name"/>
 </bag>

Solution: Move the order-by attribute to appropriate node depending on which table holds the sorted field.

Solution to MySQLSyntaxErrorException: Unknown column ‘xxxxx_.elt’ in ‘field list’

Bug: The above exception thrown when using hibernate.

Reason: This usually occurs when column name is not mentioned in many-to-many node.
The correct mapping for a many to many relation is –

  	<bag name="projects".... table="users_projects" >
  		<key column="userId"/>
  		<many-to-many column="projectId" class="Project" />
  	</bag>

Solution: The mapped columns should be provided in the key and many-to-many nodes as above.

Spring security 3 – How to display login errors ?

Heres how we display different error messages for the different cases of authentication failures like bad credentials, credentials expired etc.

Step 1. Configure an authentication failure handler in the application context.

	<beans:bean id="authenticationFailureHandler"
		class="org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler">
		<beans:property name="exceptionMappings">
			<beans:props>
				<beans:prop key="org.springframework.security.authentication.BadCredentialsException">/login/badCredentials</beans:prop>
				<beans:prop key="org.springframework.security.authentication.CredentialsExpiredException">/login/credentialsExpired</beans:prop>
				<beans:prop key="org.springframework.security.authentication.LockedException">/login/accountLocked</beans:prop>
				<beans:prop key="org.springframework.security.authentication.DisabledException">/login/accountDisabled</beans:prop>
			</beans:props>
		</beans:property>
	</beans:bean>

Step 2. Refer this handler in the form-login node of http namespace configuration.

 <form-login login-page='/login' default-target-url="/home"  authentication-failure-handler-ref="authenticationFailureHandler"/>

Step3. Capture the different URL extensions configured in step 1 in the login controller. (The example below uses Spring MVC)

    @RequestMapping(value = "/login/{error}", method = RequestMethod.GET)
   
    public final String displayLoginform(Model model,  @PathVariable final String error) {
        model.addAttribute("error", error);
    	return "login";
    }

Step 4. Check the attribute error in the JSP and print appropriate message for each case.

Done !

Error: attribute property is mandatory for tag authentication

Bug: The exception thrown when migrating to spring 3.

Reason:  This exception thrown when migrating to spring-security 3 occurs due to spring 3 (authentication tag) using the attribute “properties” in place of “operation” used by previous versions.

Solution : Use <sec:authentication property=”principal.role”/> instead of <sec:authentication operation=”role”/>