Friday, March 14, 2008

A Phone screen..

Had a phone screen with a techie firm from the bay area, Here are some of the questions:

1. Explain a 3 tier web application?
2. What is an n-tier web appliaction?
3. Explain the MVC pattern..
4. How do you implement a login functionality with an MVC?
5. How does the browser back button or refresh affect the login functionality?
6. How do you secure the password? (get or post?)
7. Describe a situation where get would be better.
8. Explain the principles of Ajax?..
9. Which browser object is responsible for getting and posting the request in Ajax?
10. Which html tag would you use to create a list of numbers on a html page?
11. What is the difference between an HTML div and an HTML span tag.
12. Implement a function that returns 1 when 2 is passed and vice versa.
13. Implement the above with divison or bit shift
14. Which one would be most efficient in terms of memory and performance for Q.12: If-else or Array or HashMap or 13?
15. What is SQL injection? How to protect the final query from becoming ill formed due to use of keywords in the form input?

Wednesday, March 12, 2008

Java Version upgrade

Problem: A site runs a java applet that is not compatible with java 6 (1.6). The browser, IE has automatically downloaded the upgrade for java 1.6 and started using it. The site needs to be accessed through the browser, so get the browser to use Java 1.4 to run java applets.

Solution 1 (didn't work): Change applet runner settings in Control Panel - Java
Solution 2 (didn't work): Remove java version 6 from IE add ons.
Solution 3 (worked): Uninstall java 6, reinstall java 4.

Wednesday, March 5, 2008

An HTTP Client

Problem: www.nse-india.com provides the historical data for shares traded. Company price data for any day starting from 1987 November can be accessed by filling a set of online forms through a browser.

e.g. the url for Jan 22 2007 will be:

http://www.nse-india.com/content/historical/WDM/2007/JAN/wdmlist_22012007.csv

Now, download the data for 10 years automatically and store it into a MS Access database.

My Solution:

1. Create a module to dynamically generate the urls for each day in the 10 year period.
2. Use Apache's HttpClient to submit the request at the generated URL: http://hc.apache.org/downloads.cgi
3. Create a module to parse the reponse String into Beans. Use Apache DateUtils.
4. Use JDBC-ODBC connectivity to connect the java code to MS access
5. create a DAO module with java.sql.PreparedStatement to insert the beans into an MS-Access table.

Bugs encountered:

1. Compiler error: Apache HttpClient classes not found.
Fix: Move jars to the folder /jdk/jre/lib/ext. No need to touch the classpath if the jars go here.
2. Class not found error: HttpClient classes don't get loaded at runtime.
Fix: Move the path entry for the JDK to the beginning of the path string. Cause of the error is that there are several JREs in the system and the java command is running from a JRE which is not inside the JDK which ran the javac.
3. No errors or exceptions, but the data doesn't load into the database:
Fix: close the PreparedStatement after use/insertion.