Jsp to Servlet converter

Jsp to Servlet converter

Here is the Ant build file to convert jsp file to servlet file.

jspc (JavaServerPages Compiler) tool is helping to convert the jsp. The requirements are you need

  • java sdk
  • apache tomcat
  • ant

The build.xml is

<project name="Test" default="compile" basedir=".">

    <description>

        JSP to Servlet Converter

    </description>

<property name="name" value="JSP to Servlet" />

<property environment="env" />

<property name="ANT_HOME" value="${env.ANT_HOME}" />

<property name="TOMCAT_HOME" value="D:\server\Tomcat 5.5" />

  <target name="init" description="Initialization" >

    <path id="tomcat.classpath">

      <fileset dir="${TOMCAT_HOME}\common\lib">

            <include name="*.jar" />

      </fileset>

    </path>

    <path id="ant.classpath">

      <fileset dir="${ANT_HOME}\lib">

            <include name="*.jar" />

      </fileset>

    </path>

    <path id="webapp.classpath">

      <fileset dir=".\WEB-INF\lib">

            <include name="*.jar" />

      </fileset>

    </path>

  </target>

  <target name="compile" depends="init" description="compile the source" >

    <mkdir dir="./out" />

    <jspc srcdir="."

          destdir="out"

          verbose="9">

      <classpath>

            <path refid="tomcat.classpath" />

            <path refid="ant.classpath" />

            <path refid="webapp.classpath" />

      </classpath>

      <include name="*.jsp" />

    </jspc>

  </target>

  <target name="build" depends="compile"/>

  <target name="clean" description="clean the directories">

      <delete dir="./out" />

  </target>

</project>
Posted in Programming | Tagged | Leave a comment

Java offline Documentation

Java offline Documentation

why it is need ..?

If you not have or limited bandwidth internet connecion in your machine at that time it is very helpfull to solve your java programming problems. The java documentation of your project is help to easily understand the classes and functions used in that project.

How to create a java documentation ..?

It is very easy using the javadoc tool you can create a documentation for any java program. First create a documentation for java

In windows:

Extract that C:\Program Files\Java\jdk1.6.0_10\src.zip to C: then

C:\>cd src

C:\src>dir /s /b *.java > files.txt

C:\src>javadoc -J-Xmx756m @files.txt

In Linux:

[root@localhost ~]# cd /usr/local/java/jdk1.6.10

[root@localhost ~]# find -r *.java > files.txt

[root@localhost ~]# javadoc -J-Xmx756m @files.txt
Posted in Programming | Tagged | Leave a comment

Soundcard in xen vm

Enable sound card in xen vm

How to enable sound card in the xen based vm..?

The vmware vm have the functionalists for adding sound card to their vm’s. Then what about xen vm

By adding the below line to your HVM (Hardware Virtual Machine) file, You can add the sound card for the virtual machine.

audio=1
soundhw='sb16,es1370'

If you play a sound file it you can hear the sound from VMM sound out. Then your hvm file is look like

name="sound-card"
builder = "hvm"
memory = "1024"
vif = [ 'type=ioemu, mac=00:16:3e:a0:0:8, bridge=xenbr0' ]
device_model = "/usr/lib/xen/bin/qemu-dm-sync"
kernel = "/usr/lib/xen/boot/hvmloader"
vnc=1
vncunused=0
vnclisten="0.0.0.0"
apic=1
acpi=0
pae=1
vcpus=2
boot='c'
audio=1
soundhw='sb16,es1370'
usb=1
usbdevice='tablet'
disk = ['file:/vm/sound-card/disk,ioemu:hda,w',
'phy:/dev/zero,hdd:cdrom,r']

Now Goto the controlpanel now the sound devices is enabled…

Posted in Linux, Virtualization | Tagged , | Leave a comment

Read properties file using Batch

Read a properties file using bat file

i want to read a below property file and get the particular key value

My properties file look like

name=arulraj.net
version=1.0.2
date=24/March/2010

I want get the version from the properties file. you can do this by various method.

Using Type function:

C:\Users\Arul\Desktop>type test.properties | find “version”

There is disadvantage with this method you could not store that value in a variable.

Using For Loop:

C:\Users\Arul\Desktop>FOR /F %i IN (test.properties) DO echo %i

using this command you can read that file by line by line.

FOR /F “eol=; tokens=2,2 delims==” %i IN (test.properties) DO echo %i

Using this commend you can get the values only.

eol is End of Line

tokens is specify the which tokens are displayed – 2,2 means only the second token will be displayed

delims is the deliminator . this is the separator

FOR /F "eol=; tokens=2,2 delims==" %i IN ('findstr /i "version" test.properties') DO set version=%i

Using findstr get the correct string from the properties file and give as a input to the for loop. That for loop process the result and set that value to the variable version.

findstr /i means is not a case sensitive one

using echo you can get the value.

echo %version%

When you using in a bat add a % befor %i. That is Look like

FOR /F "eol=; tokens=2,2 delims==" %%i IN ('findstr /i "version" test.properties') DO set version=%%i
echo %version%

Posted in Programming | Tagged , | 1 Comment

How Singleton pattern in Java

How Singleton pattern in Java

What is singleton ..?

It is a Design pattern. At this time what is Design pattern ..? To find out the best way to do a thing apart from the various method. Documenting a solution for the common problems.

The Rule for the Singleton are:

  • restrict the creating the object of the class
  • only one object is created over the application
  • If multiple thread accessed then thread safe

How to restrict the creating object..?

Define the access modifier of the constructor be Private and add the final keyword to the class then only the class can’t be extended.

Then How to create a one instance and access ..?

Create a instance with in the same class and accessed using the static method.

Here is the Example code:

public final class SingletonExample {
	private static SingletonExample singleton = new SingletonExample();
	private SingletonExample() {
		// Write your Functionality Here
	}
	public static SingletonExample getInstance() {
		return singleton;
	}
}

Usage: save the below as Arul.java

class Foo {
	public static SingletonExample obj;
	public static void method() {
		obj = SingletonExample.getInstance();
	}
}
class Arul{
	public static void main(String arg[]) {
		SingletonExample obj = SingletonExample.getInstance();
		Foo.method();
		if (Foo.obj == obj) {
			System.out.println("Both the objects are same ");
		} else {
			System.out.println("Not the same ");
		}
	}
}

In the Both Foo and Arul class access the same instance.

For more : http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29

Posted in Programming | Tagged , | Leave a comment

How to add www to your domain name

How to add www to your domain name


Before going to the htaccess . You need to answer my question, The question is

Do you think arulraj.net and www.arulraj.net both are different domain name or same ..?

ya. we (humans) know both are points the same web page. But the search engine robots assume this both are different one. As a result duplicate results in the search results. To avoid this problem you need to develop search engine friendly web pages.

Now the topic,

How to add www in front of your domain name ..?

For this you are aware of htaccess file and where it is located. htaccess – Hypertext Access

The file located in root directory of your domain name .

For example : /home/<username>/public_html/<domain dir name>/.htaccess

That above structure in Bluehost.Now add this line to your .htaccess file

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sharedaa\.com$ [NC]
RewriteRule ^(.*)$ http://www.sharedaa.com/$1 [R=301,L]

Now anyone type sharedaa.com in browser it is automatically redirect to www.sharedaa.com

How to redirect to index page if the page is not available ..?

One of your page is indexed in search engine. You remove the page, at this time you want to redirect to home page. how to do this.Add the below line to your htaccess file.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</pre>

The final .htaccess file will be

# Use PHP5CGI as default
AddHandler application/x-httpd-php5 .php

# BEGIN
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sharedaa\.com$ [NC]
RewriteRule ^(.*)$ http://www.sharedaa.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END

How to add www to your wordpress blog ..?
Go to Setting –> General setting page and in the Blog Address text box enter your domain name with www . for example htt://www.sharedaa.com

Reference : http://www.thesitewizard.com/apache/index.shtml

Posted in Programming, Uncategorized | Tagged , | Leave a comment

Flash Player Debugger

Flash Player Debugger

How to get the flash player debugger version …?

You can download the flashplayer debugger version from here http://www.adobe.com/support/flashplayer/downloads.html .

The direct download link for windows is For IE and for mozilla . Using the debugger version the trace output will be printed in flashlog.txt .

The flashlog.txt path

For windows xp is “C:\Documents and Settings\<login username>\Application Data\Macromedia\Flash Player\Logs\flashlog.txt ”

For Windows Vista and windows 7 is : “C:\Users\<login username>\AppData\Roaming\Macromedia\Flash Player\Logs\flashlog.txt”

Debugging ..?

If the trace not shown on the log create mm.cfg file .

Create a file for windows xp c:\Documents and Settings\mm.cfg
for vista C:\Users\<login username>\mm.cfg with the following

ErrorReportingEnable=0
TraceOutputFileEnable=1
MaxWarnings=0
Posted in Flash, Widget | Tagged , , , | Leave a comment

How rotation camera3d and viewer3d worked in Away3d

Rotation in Away3D Flash engine

In this blog entry we are going to learn about How the Rotation and camera3d and viewer3d in away3d flash engine.

Red line = x-axis

Blue line = y-axis

Green Line = z-axis

How Rotation works ..?

Rotation in away3d based on the three axis . Those are x.y and z.  the component is rotated take any one of this axis as a center then rotated. In my last post the sphere is rotated along with x axis. In that example the axis is like that (see below )


sphere.rotationX = sphere.x + 1;

The sphere takes x axis as a center and rotate like above…

In this example we add two or more components in the ObjectContainer3D then rotate this objects. In this example we are going to learn about how camera3D and Viewer3D works.

How Camera3D works ..?

Camera3d = real camera

view3d = lens the viewr of the camara

renderer = recording in real cam

scen3d = what we seen

This diagram explained in Papervision3d Essential book.. In this diagram your clearly understood about camera3d.

If we assume Camera 3d is like a real camera . we assume it is with in our application in invisible mode.

The viewerport (view3d) is an lens or what you are view using the camera.

The render engine is recording engine in the real camera. In the real camera If  we start the record then only we can see the changes otherwise not. Like same as in camera3d we called

viewer.render()

method each time if anything changed in the components. In the real camara If any person is not inside the seen they are not come in the flim. Same as in the scene3d if we not add add any components in the scene 3d objects  it is not visible.

How Viewer3D Works ..?

Download the source code click here (compatible for Flashdevelop IDE)

Posted in Flash, Programming | Tagged , | Leave a comment

My first 3D flash animation

3D Animathion

Adobe support for native 3D only in cs4. There are lot of opensource flash 3d engines are there. I tried papervision3d and away3d. Both are quite well. There are lot more tutorials for both online for away3d tutorials  click here , for papervision3d download this book . I got the source code of away3d from the google code http://code.google.com/p/away3d/ and for papervison3d svn http://code.google.com/p/papervision3d/. I generate swc using the command. The red5 says about away3d.

D:\sdk\Away3D&gt;compc -include-sources ./src -source-path ./src -target-player 10 -output Away3d.swc

Initially i got this error when compile away3d “Error: Type was not found or was not a compile-time constant: Vector. in away3d”

Then i added the -target-player 10 in command line is fix that error. I think away3d is better than papervision3d.Here is my first animation here

Iam using away3d here…

If not shown http://sites.google.com/site/arulraj1985/list-of-files/away3d.swf

package
{
	import away3d.cameras.Camera3D;
	import away3d.cameras.HoverCamera3D;
	import away3d.cameras.TargetCamera3D;
	import away3d.containers.ObjectContainer3D;
	import away3d.containers.Scene3D;
	import away3d.containers.View3D;
	import away3d.core.math.Number3D;
	import away3d.materials.BitmapMaterial;
	import away3d.materials.WireColorMaterial;
	import away3d.primitives.Cube;
	import away3d.core.render.Renderer;
	import away3d.primitives.Sphere;
	import away3d.primitives.WireSphere;
	import away3d.core.utils.Cast;
	import away3d.core.utils.CastError;
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	/**
	 * ...
	 * @author Arul
	 */
	public class FirstApplication extends Sprite
	{
		public var viewer:View3D;
		public var scene:Scene3D;
		public var camera:Camera3D;
		public var cube:Cube;
		public var sphere:Sphere;
		public var wiresphere:WireSphere;
		public var group:ObjectContainer3D;
		public var material:WireColorMaterial;
		public var bitmapMaterial:BitmapMaterial;

		[Embed(source = "assets/favicon.jpg")] private var favicon:Class;
		public var image:Bitmap = new favicon();

		[SWF(backgroundColor="#EEE8DA")]

		public function FirstApplication()
		{
			init3D();
		}

		public function init3D():void {
			stage.frameRate = 30;
			camera = new Camera3D({y:400,z:-1000});
			viewer = new View3D({camera:camera,x:250,y:100,z:100});
			scene = new Scene3D();
			cube = new Cube();
			sphere = new Sphere();
			wiresphere = new WireSphere();
			group = new ObjectContainer3D();
			material = new WireColorMaterial();
			bitmapMaterial = new BitmapMaterial(Cast.bitmap(image));

			material.color = 0xA6111D;

			sphere.x = 100;
			sphere.y = 50;
			sphere.z = 100;
			sphere.radius = 75;
			sphere.bothsides = true;
			sphere.material = material;
			group.addChild(sphere);

			wiresphere.x = 270;
			wiresphere.y = 150;
			wiresphere.z = 150;
			wiresphere.radius = 75;
			wiresphere.bothsides = true;
			wiresphere.material = material;
			group.addChild(wiresphere);

			cube.x = 250;
			cube.y = 250;
			cube.z = 400;
			cube.material = bitmapMaterial;
			group.addChild(cube);

			viewer.scene.addChild(group);
			viewer.render();

			addChild(viewer);

			addEventListener(Event.ENTER_FRAME, groupRotation);
			group.addEventListener(Event.ENTER_FRAME, sphereRotation);
			//addEventListener(MouseEvent.MOUSE_DOWN, lookThere);
		}

		public function groupRotation(e:Event):void {
			group.rotationX = group.x + 1;
			group.applyRotations();

			viewer.render();
		}

		public function sphereRotation(e:Event):void {
			sphere.rotationX = sphere.x + 1;
			sphere.applyRotations();

			wiresphere.rotationZ = wiresphere.z + 1;
			wiresphere.applyRotations();
			viewer.render();
		}

		public function lookThere(e:MouseEvent):void {
			var clickpoint:Point = new Point(e.stageX, e.stageY);
			var hypothines:Number = Point.distance(new Point(0, 0), clickpoint);
			var sine:Number = Math.asin(e.stageX/hypothines);
			var cos:Number = Math.acos(e.stageY/hypothines);
			camera.lookAt(new Number3D(e.stageX, e.stageY, hypothines));
			/**
			 * Horizontal angle
			 */
			camera.pan(cos);
			/**
			 * vertical angle
			 */
			camera.tilt(sine);
			viewer.render();
		}

	}

}
Posted in Flash, Programming | Tagged , , | 1 Comment

How to install mplayer on fedora ..?

How to install mplayer on fedora

http://www.haifux.org/lectures/134/lecture/images/mplayer.png

When i try to install mplayer-1.0-0.102.20080903svn.fc10.src.rpm in fedora i got this error. i download this file from rpmfusion

[root@localhost Media]# rpm -ivh mplayer-1.0-0.102.20080903svn.fc10.src.rpm
warning: mplayer-1.0-0.102.20080903svn.fc10.src.rpm: Header V3 DSA signature: NOKEY, key ID 49c8885a
1:mplayer                warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
########################################### [100%]

I have the same problem when i try to install wine-1.0.1-1.el4.i386.rpm

I have not internet connection in my home pc. so what to do..?
i goes to “/usr/src/redhat/SOURCES” folder there is a file called mplayer-export-2008-09-03.tar.bz2
Extract the file and configure it then make and make install.
Now i have mplayer in my home pc

[root@localhost Movies]# mplayer 2012.avi
MPlayer dev-SVN-r27514 (C) 2000-2008 MPlayer Team
CPU: Intel(R) Pentium(R) 4 CPU 3.00GHz (Family: 15, Model: 4, Stepping: 3)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2

Playing 2012.avi.
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
AVI: ODML: Building ODML index (2 superindexchunks).
VIDEO:  [XVID]  608x272  12bpp  29.970 fps  674.6 kbps (82.4 kbyte/s)

when i play the avi file using mplayer it does not play the video only play the audio

Now i changed the command

[root@localhost Movies]# mplayer -vo x11 -ao alsa 2012.avi

Now working fine

Posted in Linux | Tagged , | Leave a comment