Sunday, 19 August 2007

Ajax example for communicating with service side

Requested file :

* test.html - main html test page
* echo.php - php file as a source for display
* jslb_ajax.js - ajax component javascript file

******* jslb_ajax.js ***********
Download jslb_ajax.js

******* echo.php *****
<?php

//get Post request
$data = $_POST['data'];
$data = "receive ".$data." value now.";

// HTML entity (change < to ....)
$data = htmlspecialchars($data, 0, "UTF-8");

// URI encoding
$data = rawurlencode($data);

// setup UTF-8 for output
mb_http_output ('UTF-8');

// output
echo($data);
?>


**** test.html ****
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="Javascript" src="jslb_ajax.js" charset="utf-8"></script>
<script type="text/javascript">
function clickButton() {
sendRequest(load_xmlFile, '&data=abcd', 'POST', './echo.php', true, true);
}

function load_xmlFile(oj) {
var xmlDoc = oj.responseXML;
var nodes = xmlDoc.getElementsByTagName("testdata");
alert(nodes[0].firstChild.nodeValue);
}
</script>
<title>Test page</title>
</head>
<body>
<br>
<form>
<input type="button" value="send abcd to server side" onclick="clickButton()">
</form>
</body>
</html>

AJax example for reading xml file

Requested file :

* test.html - main html test page
* test.xml - xml file as a source for reading
* jslb_ajax.js - ajax component javascript file

******** test.xml *******
<?xml version="1.0" encoding="UTF-8"?>
<testdata> this is the text source part </testdata>

******* jslb_ajax.js ***********
download ajax component

***** test.html ******
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="Javascript" src="jslb_ajax.js" charset="utf-8"></script>
<script type="text/javascript">
function clickButton() {
sendRequest(load_xmlFile, '', 'GET', 'test.xml', true, true);
}

function load_xmlFile(oj) {
var xmlDoc = oj.responseXML;
var nodes = xmlDoc.getElementsByTagName("testdata");
alert(nodes[0].firstChild.nodeValue);
}
</script>
<title>Test page</title>
</head>
<body>
<br>
<form>
<input type="button" value="read test.xml and display it" onclick="clickButton()">
</form>
</body>
</html>

Sunday, 12 August 2007

Simple URL Object example

import java.net.*;

class testURL {
public static void main(String args[]) throws MalformedURLException {
URL testURL1 = new URL("http://help.blogger.com/bin/static.py?page=start.cs");
// create cs URL object
System.out.println("Protocal : " + testURL1.getProtocol());
System.out.println("Port: " + testURL1.getPort());
System.out.println("Host: " + testURL1.getHost());
System.out.println("File(include full location): " + testURL1.getFile());
System.out.println("full URL: " + testURL1.toExternalForm());
}
}

Tuesday, 7 August 2007

Memory Hipe

Create below bat file

@echo OFF

set JAVA_OPTIONS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n

"%JAVA_HOME%"\bin\java %JAVA_OPTIONS% -Xmx256m -jar org.eclipse.osgi_3.2.2.R32x_v20070118.jar -console

********** Or create enviroment value **********
JAVA_OPTION / -Xmx256m


===== There is another option for it ======================

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=15&t=000785

You can increase heap size for tomcat by setting an environment variable for that
1. right click on My Computer icon
2. click properties option
3. click advanced tab
4. click Environment Variables button
5. click New button under System Variables
6. type JAVA_OPTS in the Variable Name box
7. type -Xms512m -Xmx128m in the variable value box
8. click Ok and then Ok and then Ok
enjoy …

++++++++++++ incluses heap size of Tomcat +++++++++++++++++

http://www.chemaxon.com/jchem/doc/admin/tomcat.html

Summary
1. Right button click from "my computer" in window explore
2. Click property
3. click advance tab
4. click Enviroment variable
5. create classpath variable
6. variable name > "CATALINA_OPTS"
variable value > "-server -Xmx128m"



3.1 Recommended JVM options
There are two important Java options which should be set for Tomcat.
Maximum heap size: this is the maximum amount of heap memory the Java Virtual Machine (JVM)
is allowed to allocate.
In the case of most JVMs, the default setting of the maximum heap size is 64MB.
You can increase the maximum heap size of applications by setting the -Xmx JVM parameter.
For example -Xmx1024m allows maximum 1GB (1024MB) heap to be allocated for the JVM.

Note: it is recommended to specify a considerably lower value than the amount
of physical RAM in your system,
so the operating system and other applications will also have enough space.
Otherwise the swap memory of the operating system will be used,
which can result in high disk activity, and reduced system performance.

Server mode: server mode instructs the JVM to perform more extensive run-time optimization.
Right after startup it means a slightly slower execution,
but after the JVM had enough time to optimize the code,
the execution will be considerably faster.

3.2 Setting JVM options for Tomcat

Windows running Tomcat 5 and later : Go to the "Apache Tomcat 5.0" folder in the Start Menu.
Start the "Configure Tomcat application".
Note: the configuration can only be started when Tomcat is not running.
Select the "Java VM" tab in the configuration dialog.
You will see some pre-defined lines in the "Java Options" test box.
Append your Java options at the bottom of the option list. For example,
to set server mode and allow 512MB of heap memory, append the following:
-server
-Xmx400m

Windows running Tomcat 4.1 or earlier :
place the Java options into the CATALINA_OPTS environment variable.
To do this, run Control Panel / System, select Environment Variables and
create the CATALINA_OPTS variable,
and set the desired option, for example "-server -Xmx400m".
Linux : place the Java options into the CATALINA_OPTS environment variable.
For example: "-server -Xmx400m".

sample ant file

<?xml version="1.0" encoding="UTF-8"?>
<project name="myTest" default="all">
<property name="title" value="myTest"/>
<property name="debug" value="true"/>
<property name="jar.name" value="myTest.jar"/>
<property name="libs.location" value="lib"/>
<path id="project.classpath">
<pathelement location="."/>
<pathelement location="${libs.location}/framework.jar"/>
<pathelement location="${libs.location}/servlet.jar"/>
<pathelement location="${libs.location}/http_all-2.0.0.jar"/>
</path>
<target name="all" depends="init,compile,jar"/>
<target name="init">
<mkdir dir="./classes"/>
</target>
<target name="compile">
<echo>${libs.location}</echo>
<javac destdir= "./classes" debug = "on">
<src path= "./src"/>
<classpath refid = "project.classpath"/>
</javac>
</target>
<target name="jar">
<jar basedir = "./classes"
jarfile = "${jar.name}"
compress = "true"
includes = "**/*"
manifest = "./META-INF/MANIFEST.MF"
/>
</target>
<target name="clean">
<delete dir = "./classes"/>
</target>
</project>



******************************************************************************

<?xml version="1.0"?>
<project name="MyPrinterWorkspace" default="all">

<property name="services" value="../MyPrinterWorkspace"/>
<property name="libs" value="./lib"/>

<path id="project.classpath">
<pathelement location="."/>
<pathelement location="${libs}/framework.jar"/>
<pathelement location="${libs}/servlet.jar"/>
<pathelement location="${libs}/http_all-2.0.0.jar"/>
<pathelement location="${libs}/himalaya-bundle.jar"/>
<pathelement location="./SESPControls.jar"/>
<pathelement location="./com.samsung.dpd.everest.core_0.2.0.u2a.jar"/>
<pathelement location="./com.samsung.dpd.everest.portability_0.2.0.u1aRC2.jar"/>
</path>

<target name="all" depends="init,compile,jar"/>

<target name="init">
<mkdir dir="./classes"/>
</target>

<target name="compile">
<javac destdir= "./classes" debug = "on">
<src path= "./src"/>
<classpath refid = "project.classpath"/>
</javac>
</target>

<target name="jar">
<jar basedir = "./classes"
jarfile = "./myprinterworkspace.jar"
compress = "true"
includes = "**/*"
manifest = "./META-INF/MANIFEST.MF"
/>
</target>

<target name="clean">
<delete dir = "./classes"/>
</target>

</project>

Monday, 6 August 2007

dependence package information

- MyPrinterWorkspace (copy folder from cc - label : SESP_Rel_S2.1_HQ)

- Create Plug-in

- Import copied MyPrinterWorkspace folder

- needed jar file
* should be located in package folder and link by Window > Preference > Plug-In Development > Target Platform >
Add (button) > File System > link in jar file folder

com.samsung.dpd.everest.core_0.2.0.u2a.jar
com.samsung.dpd.everest.portability_0.2.0.u1aRC2.jar
com.samsung.dpd.himalaya_0.2.0.u2a.jar
org.eclipse.equinox.http_1.0.100.v20061218.jar
org.eclipse.equinox.log_1.0.100.v20060717.jar
org.eclipse.equinox.servlet.api_1.0.0.v20060717.jar
sespcontrols.jar
com.samsung.dpd.winslow.common_0.1.7.a.jar
com.samsung.dpd.winslow.doctreestream_0.1.5.a.jar
com.samsung.dpd.winslow.jobmanagement_0.1.5.a.jar
com.samsung.dpd.winslow.portabilitysim_0.0.0.a.jar
com.samsung.dpd.winslow.scan_0.1.5.a.jar
com.samsung.dpd.winslow.store_0.1.5.a.jar
com.samsung.dpd.winslow.system_0.1.5.a.jar
com.samsung.dpd.winslow.tiffcomposer_0.1.5.a.jar

- go to Window > Preference > Plug-In Development > Target Platform
only check
com.samsung.dpd.everest.core
com.samsung.dpd.everest.portability
com.samsung.dpd.himalaya
com.samsung.dpd.winslow.common
com.samsung.dpd.winslow.doctreestream
com.samsung.dpd.winslow.jobmanagement
com.samsung.dpd.winslow.portabilitysim
com.samsung.dpd.winslow.scan
com.samsung.dpd.winslow.store
com.samsung.dpd.winslow.system
com.samsung.dpd.winslow.tiffcomposer
javax.servlet
org.eclipse.equinox.http
org.eclipse.equinox.http.servlet
org.eclipse.equinox.log
org.eclipse.osgi
org.eclipse.osgi.services
org.eclipse.osgi.util
SESPControls


- From MANIFEST.MF
- Dependencies > Imported Packages > Add
com.samsung.dpd.Controls,
com.samsung.dpd.everest.core,
com.samsung.dpd.everest.core.basics,
com.samsung.dpd.everest.core.collections,
com.samsung.dpd.everest.core.device,
com.samsung.dpd.everest.core.device.printer,
com.samsung.dpd.everest.core.device.scanner,
com.samsung.dpd.everest.core.device.store,
com.samsung.dpd.everest.core.events,
com.samsung.dpd.everest.core.imagebasics,
com.samsung.dpd.everest.core.jobmanagement,
com.samsung.dpd.everest.core.lifecycle,
com.samsung.dpd.everest.core.mfpbasics,
com.samsung.dpd.everest.core.support,
com.samsung.dpd.everest.core.systembasics,
com.samsung.dpd.everest.core.work,
com.samsung.dpd.everest.core.work.common,
com.samsung.dpd.everest.core.work.printing,
com.samsung.dpd.everest.core.work.retrieving,
com.samsung.dpd.everest.core.work.scanning,
com.samsung.dpd.everest.core.work.storing,
com.samsung.dpd.winslow.common,
javax.servlet;version="2.4.0",
javax.servlet.http;version="2.4.0",
org.osgi.framework;version="1.4.0",
org.osgi.service.http;version="1.2.0"


- Run AS > Open Run Diagram
check all Target Platform

com.samsung.dpd.everest.core
com.samsung.dpd.everest.portability
com.samsung.dpd.himalaya
com.samsung.dpd.winslow.common
com.samsung.dpd.winslow.doctreestream
com.samsung.dpd.winslow.jobmanagement
com.samsung.dpd.winslow.portabilitysim
com.samsung.dpd.winslow.scan
com.samsung.dpd.winslow.store
com.samsung.dpd.winslow.system
com.samsung.dpd.winslow.tiffcomposer
javax.servlet
org.eclipse.equinox.http
org.eclipse.equinox.http.servlet
org.eclipse.equinox.log
org.eclipse.osgi
org.eclipse.osgi.services
org.eclipse.osgi.util
SESPControls

- Click Run

- You will see this console
osgi> ss

Framework is launched.

id State Bundle
0 ACTIVE org.eclipse.osgi_3.3.0.v20070530
2 ACTIVE org.eclipse.equinox.http_1.0.100.v20061218
3 ACTIVE org.eclipse.equinox.log_1.0.100.v20060717
14 ACTIVE MyPrinterWorkspace_1.0.0
24 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605
28 ACTIVE org.eclipse.equinox.http.servlet_1.0.0.v20070606
29 ACTIVE org.eclipse.osgi.util_3.1.200.v20070605
31 ACTIVE javax.servlet_2.4.0.v200706111738
32 ACTIVE SESPControls_1.0.0
33 ACTIVE com.samsung.dpd.winslow.portabilitysim_0.0.0.a
34 ACTIVE com.samsung.dpd.winslow.jobmanagement_0.1.5.a
35 ACTIVE com.samsung.dpd.everest.portability_0.2.0.u1aRC2
36 ACTIVE com.samsung.dpd.winslow.system_0.1.5.a
37 ACTIVE com.samsung.dpd.everest.core_0.2.0.u2a
38 ACTIVE com.samsung.dpd.winslow.tiffcomposer_0.1.5.a
39 ACTIVE com.samsung.dpd.himalaya_0.2.0.u2a
40 ACTIVE com.samsung.dpd.winslow.doctreestream_0.1.5.a
41 ACTIVE com.samsung.dpd.winslow.store_0.1.5.a
42 ACTIVE com.samsung.dpd.winslow.scan_0.1.5.a
43 ACTIVE com.samsung.dpd.winslow.common_0.1.7.a


* Kill IIS server
http://localhost/MyPrinterWorkspace
==================================================================================================

- YahooDemo

- Copy all file of YahooDemo

- Create Plug-in

- Import YahooDemo

- Change Activator name : com.samsung.dpd.sesp.samples.yahoodemo.Activator

- - needed jar file
* should be located in package folder and link by Window > Preference > Plug-In Development > Target Platform >
Add (button) > File System > link in jar file folder

org.eclipse.equinox.http_1.0.100.v20061218.jar
org.eclipse.equinox.log_1.0.100.v20060717.jar
org.eclipse.equinox.servlet.api_1.0.0.v20060717.jar


- go to Window > Preference > Plug-In Development > Target Platform
only check

javax.servlet
org.eclipse.equinox.http
org.eclipse.equinox.http.servlet
org.eclipse.equinox.log
org.eclipse.osgi
org.eclipse.osgi.services
org.eclipse.osgi.util

- From MANIFEST.MF
- Dependencies > Imported Packages > Add
javax.servlet;version="2.4.0",
javax.servlet.http;version="2.4.0",
org.osgi.framework;version="1.3.0",
org.osgi.service.http;version="1.2.0"

- Run AS > Open Run Diagram
check all Target Platform

javax.servlet;version="2.4.0",
javax.servlet.http;version="2.4.0",
org.osgi.framework;version="1.3.0",
org.osgi.service.http;version="1.2.0"

- You will see this console
osgi> ss

Framework is launched.

id State Bundle
0 ACTIVE org.eclipse.osgi_3.3.0.v20070530
2 ACTIVE org.eclipse.equinox.http_1.0.100.v20061218
3 ACTIVE org.eclipse.equinox.log_1.0.100.v20060717
24 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605
28 ACTIVE org.eclipse.equinox.http.servlet_1.0.0.v20070606
29 ACTIVE org.eclipse.osgi.util_3.1.200.v20070605
31 ACTIVE javax.servlet_2.4.0.v200706111738
32 ACTIVE YahooDemo

* Kill IIS server
http://localhost/main.html

eclipse start option

change the short cut option

From :

C:\eclipse\eclipse.exe

******** For assign lots of memory ********
D:\eclipse-rcp-europa-win32\eclipse\eclipse.exe -vmargs -Xms512m -Xmx512m

**** When Eclipse display "Out Of Memory Exception : Heap Space" *****
To :
eclipse [platform options] [-vmargs [Java VM arguments]]

eclipse.exe -vm %JAVA_HOME%\jre\bin\javaw.exe -vmargs -Xmx512M