Archive for 2010

Ajax Tag Library from sourceforge.net is good to reduce the maintenance cost of our project developed in servlets,jsp or struts.To know more about this ajax tag library from sourceforge Click Here.

To download Turbo C Software from official web site http://lmgtfy.com/?q=turbo+c+download+antique+software.In that you have to register and then you are able to download freely.

To install C software in Your Windows Operating System copy all Disk2,Disk3 files individually into Disk1 and click install.exe present in your Disk1 which came with your downloaded Zip file.
                                                 (OR)
Simply Click Here to Download

To write some content into some file or read content from file and wants to store all file content in one variable and wants to dispaly this as a alert or some thing the following program will be helpful.This works in Internet Explorer.
Code:
<HTML>
<HEAD>

<SCRIPT language="JavaScript">

function WriteAndReadFile()
{
   var fso  = new ActiveXObject("Scripting.FileSystemObject");
   var fh = fso.CreateTextFile("D:\\Test.txt", true);
   fh.WriteLine("Text Example 1");
   fh.WriteLine("Text Example 2");
   fh.WriteLine("Text Example 3");
   var f;
   var str;
   f = fso.OpenTextFile("D:\\Test.txt", 1);
   var s=f.ReadLine();
   s=s+"\n"+f.ReadLine();
   s=s+"\n"+f.ReadLine();
   alert(s);
   f.Close();      

}

</SCRIPT>
</HEAD>

<BODY>
<P>
<SCRIPT language="JavaScript">  WriteAndReadFile(); </SCRIPT>
</P>
</BODY>
</HTML>

A servlet is a small Java program that runs within a Web server.Servlets receive and respond to requests from Web clients,usually across HTTP, the HyperText Transfer Protocol.

To write a Servlet Class we follow some basic steps.
1.Implement the Servlet interface available in javax.servlet package(javax.servlet.Servlet).
2.The class name of Servlet must be Public.

Syntax:
 public class BasicServlet implements Servlet
 {
                   // Here we have to implement all methods in Servlet inteface.

  }

Methods in Servlet Inteface:

public void init(ServletConfig config) throws ServletException
{

}

By seeing the above method,we easily understand the init(ServletConfig config) always throws ServletException.So we have to handle when we implement our own Servlet class.

An Example to Implement init(ServletConfig config) method with some different syntax
Ex 1:
import javax.servlet.*;
public class SampleServlet implements Servlet
{
       public void init(ServletConfig config)
       {
                  try
                 {
                         //your code

                  }
                  catch(ServletException se)  { se.printStackTrace(); }
        }

// implement remaining all methods availabe in Servelt interface with some code to properly compile the java file
}

Ex 2:
import javax.servlet.*;
public class SampleServlet implements Servlet

{
       public void init(ServletConfig config) throws ServletException
       {

                    // your code
       }
// implement remaining all methods availabe in Servelt interface with some code to properly compile the java file

}

By seeing the above two examples,it is clear that when ever we write init(ServletConfig config) method ,it is not necessary to declare throws ServletException for inti(ServletConfig config) method.
    For informing the ServeltContainer to say initilization failed we are throwing ServletException to not to put  Servelt Object in service,instead of explicity handling ServletException using try/catch blocks.If we are handling exception explicity how to inform the container about init() fail.Is there any solution in this case.Think your self.
   

The following program will launch the Notepad by Pressing button in web browser.This works in Internet Explorer only.

<html>
<head>
<script language="JavaScript" type="text/javascript">
function runReport()
{
var rep = new ActiveXObject("WScript.Shell");
rep.Run("C:\\Windows\\system32\\notepad.exe", 1, true);
}

</script>
</head>
<body>
<h1>Run a Program</h1>
This script launch the file >> c:\windows\system32\notepad.exe<p>
<button onclick="runReport()">Run Windows NotePad</button>
</body>
</html>

If we are developing a Java application which uses the Ajax Technology and wants to transform or convert XML output is necessary in most cases.
   So in conversion of those XML,we mainly get some Problems (For example in autocomplete text field which uses AJAX ,if data came from database or some other resource contains characters like '&','<','>' we get a problem.To overcome this problem follow the bellow things.

1.What ever String u get to put under opening and closing tags must be replaced.
Java Examples:
1.String s="L & T Company";
   String needed=s.replace("&","&amp;");

2. String s="ABC > XYZ";
    String needed=s.replace(">","&gt;");

Categories

Followers