Wednesday, August 29, 2012

how to set default selected item in dropdownlist in jsp

<SELECT id='naicsCode' NAME='naicsCode' class='textfield1' selectedValue='<c:out value="${viewObject.naicsCode}"/>' >

                                         <%if(viewObject.getNaicsCode().equals("")){%>
                                              <option value="" selected="selected"> </option>
                                          <%} else {%>
                                              <option value="<%=viewObject.getNaicsCode()%>" selected="selected"><%=viewObject.getNaicsCode()%></option>
                                          <%}%>
                                        <OPTION VALUE='Agriculture, Forestry, Fishing and Hunting' >Agriculture, Forestry, Fishing and Hunting</OPTION>
                                        <OPTION VALUE='Mining' >Mining</OPTION>
                                        <OPTION VALUE='Utilities' >Utilities</OPTION>
                                        <OPTION VALUE='Construction' >Construction</OPTION>
                                        <OPTION VALUE='Manufacturing' >Manufacturing</OPTION>
                                        <OPTION VALUE='Wholesale Trade' >Wholesale Trade</OPTION>
                                        <OPTION VALUE='Retail Trade' >Retail Trade</OPTION>
                                        <OPTION VALUE='Transportation and Warehousing' >Transportation and Warehousing</OPTION>
                                        <OPTION VALUE='Information' >Information</OPTION>
                                        <OPTION VALUE='Finance and Insurance' >Finance and Insurance</OPTION>
                                        <OPTION VALUE='Real Estate and Rental and Leasing' >Real Estate and Rental and Leasing</OPTION>
                                        <OPTION VALUE='Professional and Technical Services' >Professional and Technical Services</OPTION>
                                        <OPTION VALUE='Management of Companies and Enterprises' >Management of Companies and Enterprises</OPTION>
                                        <OPTION VALUE='Administrative and Waste Services' >Administrative and Waste Services</OPTION>
                                        <OPTION VALUE='Educational Services' >Educational Services</OPTION>
                                        <OPTION VALUE='Health Care and Social Assistance' >Health Care and Social Assistance</OPTION>
                                        <OPTION VALUE='Arts, Entertainment and Recreation' >Arts, Entertainment and Recreation</OPTION>
                                        <OPTION VALUE='Accommodation and Food Services' >Accommodation and Food Services</OPTION>
                                        <OPTION VALUE='Other Services (Except Public Administration)' >Other Services (Except Public Administration)</OPTION>
                                        <OPTION VALUE='Public Administration' >Public Administration</OPTION>
                                    </SELECT>

.............................................

function SetSelectedIndex(dropdownlist,sVal)
{
var a = document.getElementById(dropdownlist);
for(i=0;i<a.length;i++)
{
if(a.options[i].value == sVal)
{
a.selectedIndex = i;
}
}
}

.................................

<select name="states">
<%
for(int i=0;i<sL.size();i++)
{
if (selState.equals(sL.get(ac)))
{ %>
<option value="<%=(String)sL.get(i)%>"SELECTED><%=(String)sL.get(i)%>
<% }
else
{ %>
<option value="<%=sL.get(i)%>"><%=sL.get(ac)%>
<% } %>
</option>
<%} %>
</select> 

Tuesday, August 28, 2012

how to find the number of tables in DB2

SELECT COUNT(*) FROM syscat.tables
WHERE tabschema = 'SSCSCRD1'

Monday, August 27, 2012

Captca implementation in java

The three CAPTCHA libraries I've used for Java are:
  1. JCaptcha - This is the most configurable of the three, and pretty well documented. But we can't seem to get this to look right, no matter what. It also does audio and other unconventional CAPTCHAs
    JCaptcha example
    http://jcaptcha.sourceforge.net/
  2. SimpleCaptcha - This is reasonably configurable, and pretty well documented. I like the way this looks, but some people have trouble reading it.
    SimpleCaptcha example
    http://simplecaptcha.sourceforge.net/
  3. icaptcha - This is pretty poorly documented, but shouldn't be too hard to figure out from the examples. In our tests, we found this to be more readable than the other two (can be a good thing or a bad thing, depending on your target audience)
    icaptcha example
    http://code.google.com/p/icaptcha/
Our apps are Spring MVC based, and it was really easy to integrate these.
We just went with what looked best to us (icaptcha).

Thursday, August 9, 2012

Things to carry to onsite useful links

http://www.gadling.com/2008/11/13/top-10-things-you-must-pack-first-before-going-abroad/
http://www.scribd.com/doc/24947028/Things-to-Carry-When-Going-Onsite

http://belkud.blogspot.in/2008/07/checklist-things-to-carry-for-travel-to.html

http://matadornetwork.com/abroad/10-things-i-wish-id-known-before-studying-abroad/




Wednesday, August 8, 2012

OCR process in java

 use apire libraries

1.1 About OCR
OCR (Optical Character Recognition) is the technology that allows you to transform
images (e.g., images scanned from paper documents) into editable text-based
computer files.

package com.jnet.ocr;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.asprise.util.ocr.OCR;

public class OCRMain {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        OCR.setLibraryPath("C:/WINDOWS/system/AspriseOCR.dll");
        BufferedImage image = ImageIO.read(new File("scanned-text-100dpi.jpg"));
        System.out.println("height" + image.getHeight());
        System.out.println("width" + image.getWidth());
        System.out.println("minx" + image.getMinX());
        System.out.println("minY" + image.getMinY());

        image = image.getSubimage(75, 250, 240, 20);

        // String s = new OCR().recognizeEverything(image);

        // recognizes both characters and barcodes
        String s = new OCR().recognizeEverything(image);

        // prints the results.
        System.out.println("RESULTS: \n" + s);

    }

}

Saturday, August 4, 2012

How many objects are created for a particular class how to find?

class One
{
static int count = 0;
One()
{
count++;
System.out.println("Number of Object created :"+count);
}
public static void main(String[] args)
{
new One();
new One();
new One();
new One();
One o = new One();
}
}

Thursday, August 2, 2012

ways to know new technologies in java

http://www.javaspecialists.eu/
http://refcardz.dzone.com/
http://freecode.com/tags/java

how to dipaly processing on button in java script

<script language="javascript">
var processing = false;
function submitPage(button){
        if(!processing){
            processing = true;
            button.style.color ='#ffffff';
            button.value = 'Processing...';
            return true;
        }else{
            return false;
        }
    }

</script>


<input type='submit' name='submittor' value='Create Customer'  class='button'   onclick="return submitPage(this)" />

Wednesday, August 1, 2012

how to get real path instead of fakepath in java script

var browserName=navigator.appName;  if (browserName=="Microsoft Internet Explorer") {
   
var soloNombre = encodeURI(soloNombre);
    soloNombre
= soloNombre.replace("C:%5Cfakepath%5C","");
   
var soloNombre = decodeURI(soloNombre);
    alert
(soloNombre); }
................................

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>
<title>Testing the FakePath String</title>
</head>
<body>
<form id="Form1" action="" method="post">
<input type="file" /><input type="button" onclick="alert(this.previousSibling.value);" value="select file and press the button" />
</form>
</body>
</html>

password strength in jquery


<script language="javascript" src="js/jquery_password_strength_meter.js"></script>
<script language="javascript">
   $(function () { 
  $('#password').keyup(function(){$('#result').html(passwordStrength($('#password').val(),$('#loginName').val()))}); 
 });
</script>
<style type="text/css">
.style1 {
 font-family: Geneva, Arial, Helvetica, sans-serif;
 font-size: 12px;
}
</style>

 <td width="40%">
                                         <input type="text"
            id="loginName"
            name="loginName"
            css="textfield1"
            initValue="${viewObject.loginName}">
            <concord:event name="size" handler="30"/>
            <concord:event name="maxlength" handler="9" />
            <concord:event name="onblur" handler="if(validateLoginName(this,'Login Name')){checkAvailability();}"/> 
           /></td>
                                        <td width="60%"><label>

 <tr>
        <td  valign="top"><table width="700" border="0" align="center" cellpadding="3" cellspacing="0">
                                <tr>
                                  <td width="219" align="right">Password:<span class="red">*</span></td>
                                  <td width="464"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td width="47%" height="33"><input name="password"  type="password" class="textfield1" value='<c:out value="${viewObject.password}"/>' id="password" maxlength="8" size="30" /></td>
                                      <td width="53%" class="plft10"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                          <td class="font_grey10">Password Strength</td>
                                        </tr>
                                        <tr>
                                          <td><img src="images/customer/password-strength.gif" name="pstrength" alt="" width="93" height="7" />&nbsp;&nbsp;<span class="style1" style="color:green;" id='result'></span></td>
                                        </tr>
                                      </table> <label></label></td>
                                    </tr>