Monday, August 31, 2009

Use special characters, superscript, subscript in HTML button

To use special characters, superscript, subscript in HTML button use the <button> tag instead of <input type="button"> tag.
To use special character you can use their corresponding ASCII codes

Ex.
<button>a<sup>3</sup></button> which gives

Instances where TOMCAT server needs restart

1. Change/Addition/Deletion of web.xml file
2. Change/Addition/Deletion of jar files

Restart not required in
1. Change/Addition/Deletion of jsp file
2. Change/Addition/Deletion of html file
3. Change/Addition/Deletion of css file
4. Change/Addition/Deletion of js file
5. Change/Addition/Deletion of serlvlet (java files)??
6. Change/Addition/Deletion of class (class files)??
7. Change/Addition/Deletion of images (image files)

How to run an individual JSP

Without creating an application directory structure how would you run an individual jsp file?

Using TOMCAT
Create a folder "myapplication" within C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ and place your jsp file in it.
This is how the file path looks C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myfile.jsp

Now start the TOMCAT server.
Use the following url in your browser to run the jsp file.
http://localhost:8080/myapplication/myfile.jsp

Standard Directory Layout in TOMCAT

/Apache Software Foundation/Tomcat 6.0/webapps/myapplication/
Place the dynamic content namely html, jsp and images. You can create separate images folder (webapps/myapplication/images) to keep all the images.
/Apache Software Foundation/Tomcat 6.0/webapps/myapplication/WEB-INF/
Place the web.xml file
/Apache Software Foundation/Tomcat 6.0/webapps/myapplication/WEB-INF/lib/
Place all the jar files used by the application
/Apache Software Foundation/Tomcat 6.0/webapps/myapplication/WEB-INF/classes/
Place the dynamic content namely your servlets (java & class files)

In case of servlets any relative reference will always refer to the root directory. Hence the html code "<body background="images/bg.gif" bgcolor="#FFFFFF">" will look for the image in "/images/" folder.

You should map the servlet URL to your servlet using a mapping in the web.xml. This is a virtual mapping, no physical directories need to exist. Tomcat knows that the files it wants will be in WEB-INF/classes or WEB-INF/lib

More information could be obtained HERE & HERE

. Sample application war could be obtained HERE.

Sunday, August 2, 2009

EMI Calculator

Enter the Principal amount (the amount of loan to be taken), Rate of Interest per annum/year and the number of Months for which the loan is to be taken. The EMI would be calculated dynamically.



PrincipalRate of InterestMonths
 
  EMI  




EMI Formula = p*r*(1+r)n/{(1+r)n-1}

where
p = principal amount
r = interest rate per month (ex: if interest rate per annum is 10% then r = (10/12)/100
n = tenure in months