News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

AJAX CHARACTER DECODER in JAVA - Complie & Run!!!

Started by Kalyan, Jul 19, 2008, 03:56 PM

Previous topic - Next topic

Kalyan

AJAX CHARACTER DECODER

classpath

file .classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
   <classpathentry kind="lib" path="war/WEB-INF/lib/servlet.jar"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
   <classpathentry kind="output" path="war/WEB-INF/classes"/>
</classpath>


project

file .project

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
   <name>ch02-CharacterDecoder</name>
   <comment></comment>
   <projects>
   </projects>
   <buildSpec>
      <buildCommand>
         <name>org.eclipse.jdt.core.javabuilder</name>
         <arguments>
         </arguments>
      </buildCommand>
      <buildCommand>
         <name>com.ibm.sse.model.structuredbuilder</name>
         <arguments>
         </arguments>
      </buildCommand>
   </buildSpec>
   <natures>
      <nature>org.eclipse.jdt.core.javanature</nature>
   </natures>
</projectDescription>


Ajax

file ajax.js

  var req;

  function convertToDecimal(){
    var key = do*****ent.getElementById("key");
    var keypressed = do*****ent.getElementById("keypressed");
    keypressed.value = key.value;
    var url = "/ajaxdecimalcodeconverter/response?key=" + escape(key.value);
    if (window.XMLHttpRequest){
      req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject){
      req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    req.open("Get",url,true);
    req.onreadystatechange = callback;
    req.send(null);
  }

  function callback(){
    if (req.readyState==4){
      if (req.status == 200){
        var decimal = do*****ent.getElementById('decimal');
        decimal.value = req.responseText;
      }
    }
    clear();
  }
  function clear(){
    var key = do*****ent.getElementById("key");
    key.value="";
  }
  function focusIn(){
    do*****ent.getElementById("key").focus();
  }


Index Page

file index.html

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <SCRIPT language="JavaScript" src="ajax.js"></SCRIPT>
    <title>Ajax On Java, Chapter 2 Example</title>
  </head>
  <body onload="focusIn();">
    <h1> AJAX CHARACTER DECODER </h1>
    <h2> Press a key to find its value. </h2>
      <table>
        <tr>
          <td>
            Enter Key Here ->
            <input type="text" id="key" name="key" onkeyup="convertToDecimal();">
          </td>
      </table>
      <br />
      <table>
        <tr>
          <td colspan="5" style="border-bottom:solid black 1px;">
            Key Pressed:
            <input type="text" readonly id="keypressed">
          </td>
        </tr>
        <tr>
          <td> Decimal </td>
        </tr>
        <tr>
          <td> <input type="text" readonly id="decimal"> </td>
        </tr>
      </table>
  </body>
</html>



CSS Style



file style.css


body{
  font-family: Arial, Helvetica, sans-serif;
  font-size: small;
  text-align:center;
  background:#cbdada;
}
#keypressed{
   width:30;
   border:none;
}
#key{
  width:20px;
  padding:0;
  margin:0;
  border:none;
  text-align:left
}
h1, h2 {
  font-size:120%;
  text-align:center;
}
h2{
  font-size:110%
}
table, input{
  margin-left:auto;
  margin-right:auto;
  padding:0px 10px;
  text-align:center;
  color:black;
  text-align:center;
  background: #a0f6f5;
  border:solid black 1px;
}
td {
  margin:10px 10px;
  padding: 0px 5px;
  border: none;
}
input {
  width: 80;
  border: none;
  border-top:solid #999999 1px;
  font-size: 80%;
  color: #555555;
}