damn you jsp.I have studied almost 2 month about jsp/servlet technology to pass the scwcd exam.
Although i am not interested in web component development, i thought that i have to learn jsp technology.But things doesnt work like that.We dont need to follow technology we need to follow what is behind technology.(saint john locke smile here).now my favorites are java server faces and facelets.damn you jsp.Who likes java inside html nowadays?No thanks.I lost my appetence.Maybe after after years now somebody thinks in the same way we think for jsp/servlet for server faces and facelets.(yes this is the rule of development the big truth ladder always go forward) or maybe not. Maybe development is not a simple ladder. We are out of our imagination and we only hope to develop always.And the truht beside us something really different.Year 2099.There is no java! damn you jsp i told you not to be so bad.I hope we can leave something for future a bit of thing.There will no books to write us but internet can save us for hundreds of years too.But who knows maybe we dont need internet in 2099?Damn i am so desperate.See you in another life brother.
Saturday, March 08, 2008
Friday, February 15, 2008
First Sample Richfaces Ajax Web Application
Download echo example with neccessary jars introduced in Richfaces Developer Guide
Successfully tested in Apache Tomcat 6.0.
Call it
http://localhost:8080/DemoAjax/echo.do
Successfully tested in Apache Tomcat 6.0.
Call it
http://localhost:8080/DemoAjax/echo.do
Monday, February 04, 2008
Search For Meaning
Hakia is new search engine for meaningful searches. It is beta right now but i think it will develop and be popular quickly because it can answer intelligent questions like : what is the meaning of life:)) Or sth more beneficial : Has anyone seen Dane Cook commercials?. like its main page says.
Etiketler:
search engines
Friday, February 01, 2008
F:\RECYCLER\RECYLER
Yesterday i noticed my usb doesn't open correctly with double-click.
Kaspersky anti-virus doesnt find anything when i scanned it.In its logs it says it checked sth like F:\RECYCLER\RECYCLER and some files under it.But when i open my usb with explorer i couldnt see them.So i went to command shell in windows and typed
>ls -al
>rm -f -r RECYCLER
and what is it now gone.
I can open my usb with double-click now.
Kaspersky anti-virus doesnt find anything when i scanned it.In its logs it says it checked sth like F:\RECYCLER\RECYCLER and some files under it.But when i open my usb with explorer i couldnt see them.So i went to command shell in windows and typed
>ls -al
>rm -f -r RECYCLER
and what is it now gone.
I can open my usb with double-click now.
Wednesday, January 30, 2008
Example ivy settings.xml for artifactory repository
Below you can find settings.xml for your project.It defines dependencies for ivy.

And artifactory directory structure is like that:

Point that dependency is written like
javax/faces
NOT
javax.faces
in settings.xml
http://myserverip:port/artifactory/repo/javax/faces/jsf-api/1.1_02/jsf-api-1.1_02.jar
in ivysettings.xml
[organisation] = javax/faces
[module] = jsf-api
[revision] = 1.1_02
[artifact]-[revision].[ext] = jsf-api-1.1_02.jar
in settings.xml
[org] = javax/faces
[name] = jsf-api
[rev] = 1.1_02
Previously i wrote that artifactory can't download artifacts when I build project with ant-ivy.I realized that I should write dependencies like javax/faces NOT javax.faces.

And artifactory directory structure is like that:

Point that dependency is written like
javax/faces
NOT
javax.faces
in settings.xml
http://myserverip:port/artifactory/repo/javax/faces/jsf-api/1.1_02/jsf-api-1.1_02.jar
in ivysettings.xml
[organisation] = javax/faces
[module] = jsf-api
[revision] = 1.1_02
[artifact]-[revision].[ext] = jsf-api-1.1_02.jar
in settings.xml
[org] = javax/faces
[name] = jsf-api
[rev] = 1.1_02
Previously i wrote that artifactory can't download artifacts when I build project with ant-ivy.I realized that I should write dependencies like javax/faces NOT javax.faces.
Etiketler:
artifactory,
ivy
Tuesday, January 29, 2008
How to create project directory structure with maven archetype plugin
Nowadays i am working on a new dynamic web project which uses spring-hibernate-richfaces trio.My first task to set up development environment of project.It involves many steps.I will write sth about it occasionally.
Here I will use Maven Archetype plugin to create directory structure of my project.Assume that dynamic webproject has 3 directory initially.
core
web
security
Because we will created an internal artifactory repository and configured it we dont care about jars anymore.Project will be simply involves java classes,resources like gifs,jpegs for web side,and our pom.xmls.Jars will reside in M2_REPO which is = Your home\.m2\repository as default.
1.Create an empty directory e.g myproject
2.Go inside it
3.write in command prompt
mvn archetype:create -DgroupId=com.mycompany.myproject.core
-DartifactId=myproject-core -DarchetypeArtifactId=maven-archetype-quickstart
It will create myproject-core directory.
4.write in command prompt
mvn archetype:create -DgroupId=com.mycompany.myproject.web
-DartifactId=myproject-web -DarchetypeArtifactId=maven-archetype-webapp
It will create myproject-web directory.
5..write in command prompt
mvn archetype:create-DgroupId=com.mycompany.myproject.security
-DartifactId=myproject-security-DarchetypeArtifactId=maven-archetype-quickstart
It will create myproject-security directory.
You will see that every directory has a pattern.Thanks to this plugin you dont need to think about directory structure of your project.
For more information
http://maven.apache.org/plugins/maven-archetype-plugin/
Here I will use Maven Archetype plugin to create directory structure of my project.Assume that dynamic webproject has 3 directory initially.
core
web
security
Because we will created an internal artifactory repository and configured it we dont care about jars anymore.Project will be simply involves java classes,resources like gifs,jpegs for web side,and our pom.xmls.Jars will reside in M2_REPO which is = Your home\.m2\repository as default.
1.Create an empty directory e.g myproject
2.Go inside it
3.write in command prompt
mvn archetype:create -DgroupId=com.mycompany.myproject.core
-DartifactId=myproject-core -DarchetypeArtifactId=maven-archetype-quickstart
It will create myproject-core directory.
4.write in command prompt
mvn archetype:create -DgroupId=com.mycompany.myproject.web
-DartifactId=myproject-web -DarchetypeArtifactId=maven-archetype-webapp
It will create myproject-web directory.
5..write in command prompt
mvn archetype:create-DgroupId=com.mycompany.myproject.security
-DartifactId=myproject-security-DarchetypeArtifactId=maven-archetype-quickstart
It will create myproject-security directory.
You will see that every directory has a pattern.Thanks to this plugin you dont need to think about directory structure of your project.
For more information
http://maven.apache.org/plugins/maven-archetype-plugin/
Etiketler:
artifactory,
maven
Monday, January 28, 2008
Ant -Maven War:Ivy on the battlefield
Ivy is the new graduated dependency manager from Apache Ant project which is counterattack to Apache Maven project .
Which option is good for you?
Using ant as a build tool and then configure it via ivy maven-like behavior?Or
Using maven as a build tool and then use maven-ant tasks to get ant-like behavior?
You can find comparision of this tools in their website from 2 different perspectives.
It s up to you choose one of them.But in our internal repository server example I didnt correctly configure ivy to get jars from repository. Ivy can download jars from my repository if they are there.But if there are no jars to download artifactory can't get jars from internet which is default behaviour when I use maven.Maybe i can find answer or maybe I must use maven and ant tasks simply.who knows?But i like this war.
Which option is good for you?
Using ant as a build tool and then configure it via ivy maven-like behavior?Or
Using maven as a build tool and then use maven-ant tasks to get ant-like behavior?
You can find comparision of this tools in their website from 2 different perspectives.
It s up to you choose one of them.But in our internal repository server example I didnt correctly configure ivy to get jars from repository. Ivy can download jars from my repository if they are there.But if there are no jars to download artifactory can't get jars from internet which is default behaviour when I use maven.Maybe i can find answer or maybe I must use maven and ant tasks simply.who knows?But i like this war.
Etiketler:
ant,
artifactory,
maven
Friday, January 25, 2008
Example maven settings.xml for artifactory repository
maven settings.xml file may look like this picture
xx.xx.xx.xx :stands for internal server ip address
Etiketler:
artifactory,
maven
Configuring an internal maven repository with artifactory in Linux server
After you have successfully started artifactory service as root you need to go
http://localhost:8081/artifactory OR in our case
http://[serverip]:[serverport]/artifactory
[serverport] : Artifactory comes with an artifactory.war file.When you start artifactory service it deploys it to jetty server which comes with artifactory.So serverport must point to used webserver default port where artifactory.war is deployed. Here in this case it is 8081 for jetty.For tomcat it 8080 as you forecast.
For first-time admin log in
username :admin
password :password
If you can't log in try to reinstall artifactory.May be some files that you dont know and already exists there override default behaviour which is extremely rare case but take my 4 hours.Be sure that files are yours and clean.
Now you successfully log in to web ui of artifactory.You can deploy your jars,versioning it,do some security settings here.It is the easy part to do.
But it is not the end. We want some behaviour from artifactory repository:
We want artifactory to download needed jars for our project on our internal server so each team member can download jars from internal server and don't have to go Maven Repository or other repositories on the internet. If server doesnt find needed jar on itself It (Server!) download jars on itself after maven command executed by one of the team members.
We should do some configuration to get these behaviour.
http://localhost:8081/artifactory OR in our case
http://[serverip]:[serverport]/artifactory
[serverport] : Artifactory comes with an artifactory.war file.When you start artifactory service it deploys it to jetty server which comes with artifactory.So serverport must point to used webserver default port where artifactory.war is deployed. Here in this case it is 8081 for jetty.For tomcat it 8080 as you forecast.
For first-time admin log in
username :admin
password :password
If you can't log in try to reinstall artifactory.May be some files that you dont know and already exists there override default behaviour which is extremely rare case but take my 4 hours.Be sure that files are yours and clean.
Now you successfully log in to web ui of artifactory.You can deploy your jars,versioning it,do some security settings here.It is the easy part to do.
But it is not the end. We want some behaviour from artifactory repository:
We want artifactory to download needed jars for our project on our internal server so each team member can download jars from internal server and don't have to go Maven Repository or other repositories on the internet. If server doesnt find needed jar on itself It (Server!) download jars on itself after maven command executed by one of the team members.
We should do some configuration to get these behaviour.
Etiketler:
artifactory,
linux,
maven
Setting up an internal maven repository with artifactory in Linux server
First of all i assume that you login as a root to linux.It s neccessary to be root for executing service.
./install.sh [arg1] : This is expected to install artifactory as a linux service. [arg1] is the username of the JETTY_USER.Default is jetty.If you want to override (what i do) you can pass it an argument.(like artifactory)
my ARTIFACTORY_HOME is:
/opt/artifactory
and under ARTIFACTORY_HOME there is etc folder.Under etc execute
vi default
It should like this:
************************
#!/bin/sh
export JAVA_HOME=/opt/java/jre1.5.0_14
export JAVA_OPTIONS="-server -Xms400m -Xmx1g"
export ARTIFACTORY_HOME=/opt/artifactory
export JETTY_USER=artifactory
export JETTY_CONSOLE=${ARTIFACTORY_HOME}/logs/consoleout.log
*************************
JAVA_HOME should point to your jre folder.
JETTY_CONSOLE is where you can find log when artifactory start or may be failed to start which means 1.5 days for me.
Because my JETTY_USER is 'artifactory' there must be a user setting in /etc/init.d/artifactory.
This /etc/init.d/artifactory user MUST have read/write access to artifactory folder.So i suggest you to as a begginner in /opt/artifactory folder and simply write
chmod -R 777 *
and give full access to everybody just for beginning.You can easily configure it when you became more familiar to artifactory/linux/maven blah blah issues.
and here we go
we want to start artifactory via:
service artifactory start
If it says what the hell artifactory service is it means you did sth wrong so stop here and go steps above.Look at /opt/artifactory/etc/default file to check settings are correct.
I suggest you to open another session to linux server before executing start artifactory service and go to /opt/artifactory/logs folder
write :
tail -f consoleout.log
to see what is going on there
If it is successfully started you are lucky:) Almost every try i have a problem so be patient.
There are popular known errors:
java.lang.RuntimeException: Failed to read object from stream.
Failed to execute JcrCallback : FileNotFoundException on tmp file
I hope you successfully installed artifactory and now you can configure it.
./install.sh [arg1] : This is expected to install artifactory as a linux service. [arg1] is the username of the JETTY_USER.Default is jetty.If you want to override (what i do) you can pass it an argument.(like artifactory)
my ARTIFACTORY_HOME is:
/opt/artifactory
and under ARTIFACTORY_HOME there is etc folder.Under etc execute
vi default
It should like this:
************************
#!/bin/sh
export JAVA_HOME=/opt/java/jre1.5.0_14
export JAVA_OPTIONS="-server -Xms400m -Xmx1g"
export ARTIFACTORY_HOME=/opt/artifactory
export JETTY_USER=artifactory
export JETTY_CONSOLE=${ARTIFACTORY_HOME}/logs/consoleout.log
*************************
JAVA_HOME should point to your jre folder.
JETTY_CONSOLE is where you can find log when artifactory start or may be failed to start which means 1.5 days for me.
Because my JETTY_USER is 'artifactory' there must be a user setting in /etc/init.d/artifactory.
This /etc/init.d/artifactory user MUST have read/write access to artifactory folder.So i suggest you to as a begginner in /opt/artifactory folder and simply write
chmod -R 777 *
and give full access to everybody just for beginning.You can easily configure it when you became more familiar to artifactory/linux/maven blah blah issues.
and here we go
we want to start artifactory via:
service artifactory start
If it says what the hell artifactory service is it means you did sth wrong so stop here and go steps above.Look at /opt/artifactory/etc/default file to check settings are correct.
I suggest you to open another session to linux server before executing start artifactory service and go to /opt/artifactory/logs folder
write :
tail -f consoleout.log
to see what is going on there
If it is successfully started you are lucky:) Almost every try i have a problem so be patient.
There are popular known errors:
java.lang.RuntimeException: Failed to read object from stream.
Failed to execute JcrCallback : FileNotFoundException on tmp file
I hope you successfully installed artifactory and now you can configure it.
Etiketler:
artifactory,
linux,
maven
Tuesday, January 22, 2008
Object Mentor
http://www.objectmentor.com/resources/publishedArticles.html
Very useful for software development.Especially Articles For Craftsman section. You can begin your jouney as an apprentice of Master Mr.C...
Very useful for software development.Especially Articles For Craftsman section. You can begin your jouney as an apprentice of Master Mr.C...
Monday, December 24, 2007
The way of testivus
Good test fails
The pupil went to the master programmer and said:
“All my tests pass all the time. Don’t I deserve a raise?”
The master slapped the pupil and replied:
“If all your tests pass, all the time, you need to write better tests.”
With a red cheek, the pupil went to HR to complain.
But that’s another story.
Enjoy the way of testivus in www.junitfactory.com . Write tests write tests tests tests...........
The pupil went to the master programmer and said:
“All my tests pass all the time. Don’t I deserve a raise?”
The master slapped the pupil and replied:
“If all your tests pass, all the time, you need to write better tests.”
With a red cheek, the pupil went to HR to complain.
But that’s another story.
Enjoy the way of testivus in www.junitfactory.com . Write tests write tests tests tests...........

Wednesday, December 19, 2007
Interesting java compiler errors#1
public class Test2 {
public enum Dogs {collie, harrier, shepherd};
public static void main(String [] args) {
Dogs myDog = Dogs.shepherd;
switch (myDog) {
case Dogs.collie:
System.out.print("collie ");
default:
System.out.print("retriever ");
case harrier:
System.out.print("harrier ");
}
}
}
what is the error?
an enum switch case label must be the unqualified name of an enumeration constant
public enum Dogs {collie, harrier, shepherd};
public static void main(String [] args) {
Dogs myDog = Dogs.shepherd;
switch (myDog) {
case Dogs.collie:
System.out.print("collie ");
default:
System.out.print("retriever ");
case harrier:
System.out.print("harrier ");
}
}
}
what is the error?
an enum switch case label must be the unqualified name of an enumeration constant
Etiketler:
java compiler
Friday, November 30, 2007
JSF-Spring Integration
If you follow this link you can easily your existing web application which uses JSF with spring.
But when you run tomcat 6.0 you can take this output in console.
java.lang.IllegalStateException: No thread-bound request found: Are you
But when you run tomcat 6.0 you can take this output in console.
java.lang.IllegalStateException: No thread-bound request found: Are you
> referring to request attributes outside of an actual web request?
> If you are actually operating within a web request and still receive this
> message,your code is probably running outside of
> DispatcherServlet/DispatcherPortlet: In this case, use
> RequestContextListener or RequestContextFilter to expose the current
> request.
It is because of this:
http://www.jdocs.com/page/AjaxSourceCode?oid=62833
at line 102
You can fix it with modify your web.xml. Add this listener to your web.xmlorg.springframework.web.context.request.RequestContextListener
As a result, your working web.xml should contain listeners below.//listeners com.sun.faces.config.ConfigureListener org.springframework.web.context.ContextLoaderListener org.springframework.web.context.request.RequestContextListener de.mindmatters.faces.spring.context.ContextLoaderListener
//end of listeners
Thursday, October 18, 2007
Does Java pass by reference or pass by value?
Link
Java copies and passes the reference by value, not the object. Thus, method manipulation will alter the objects, since the references point to the original objects. But since the references are copies, swaps will fail. Unfortunately, after a method call, you are left with only the unswapped original references. For a swap to succeed outside of the method call, we need to swap the original references, not the copies.
-------------------------------------------------------------------------------------------------
int x = 5;
int y = 7;
int tmp = x;
x = y;
y = tmp,
If all your variables are local to one method, it doesn't matter whether
they are primitives or references, you can use their values any way you
like.
The problem, which you don't seem to have grasped, comes when these
variables are passed onto other methods.
In C you can do this:
void swap(int *x, int *y) {
int tmp = *x;
*x = *y;
*y = tmp;
}
In Java, you can't. Not with primitive types, anyway. But if you have
some sort of wrapper object, you can do this:
void swap(IntWrapper x, IntWrapper y) {
int tmp = x.getValue();
x.setValue(y.getValue());
y.setValue(tmp);
}
You can't do this with java.lang.Integer as it doesn't have methods to
change its value, but you can write your own wrapper class.
int wrapper(sth old)
Java copies and passes the reference by value, not the object. Thus, method manipulation will alter the objects, since the references point to the original objects. But since the references are copies, swaps will fail. Unfortunately, after a method call, you are left with only the unswapped original references. For a swap to succeed outside of the method call, we need to swap the original references, not the copies.
-------------------------------------------------------------------------------------------------
int x = 5;
int y = 7;
int tmp = x;
x = y;
y = tmp,
If all your variables are local to one method, it doesn't matter whether
they are primitives or references, you can use their values any way you
like.
The problem, which you don't seem to have grasped, comes when these
variables are passed onto other methods.
In C you can do this:
void swap(int *x, int *y) {
int tmp = *x;
*x = *y;
*y = tmp;
}
In Java, you can't. Not with primitive types, anyway. But if you have
some sort of wrapper object, you can do this:
void swap(IntWrapper x, IntWrapper y) {
int tmp = x.getValue();
x.setValue(y.getValue());
y.setValue(tmp);
}
You can't do this with java.lang.Integer as it doesn't have methods to
change its value, but you can write your own wrapper class.
int wrapper(sth old)
Tuesday, July 31, 2007
how to install windows xp to sata disk notebook
1.Enter boot menu
2.Advanced-AHCI Configuration make it disabled
3.Install xp now!!
2.Advanced-AHCI Configuration make it disabled
3.Install xp now!!
Tuesday, April 24, 2007
how to send image from mobile phone to servlet :Server Side
BufferedReader reader = request.getReader();
ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
int width=160;
int height=120;
int [] pixels = new int[width*height];
int ch;
BufferedImage img=
new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
FileWriter fw1;
BufferedWriter bw1=null;
try{
File myfile = new File("C:\\picture.jpg");
fw1 = new FileWriter("C:\\imagedata.txt");
bw1 = new BufferedWriter(fw1);
for(int i =0;i LT 120;i++){
for(int j=0;j LT 160;j++){
reader.skip(1);
ch=reader.read();
while ((ch = reader.read()) != '?')
bStrm.write(ch);
String str = new String(bStrm.toByteArray());
pixels[i*160+j] = Integer.parseInt(str);
bw1.write(""+pixels[i*160+j]);
bStrm.reset();
}
bw1.newLine();
}
img.setRGB(0,0,160,120,pixels,0,160);
ImageIO.write(img,"jpg",myfile);
}catch(Exception e){
}
bw1.close();
ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
int width=160;
int height=120;
int [] pixels = new int[width*height];
int ch;
BufferedImage img=
new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
FileWriter fw1;
BufferedWriter bw1=null;
try{
File myfile = new File("C:\\picture.jpg");
fw1 = new FileWriter("C:\\imagedata.txt");
bw1 = new BufferedWriter(fw1);
for(int i =0;i LT 120;i++){
for(int j=0;j LT 160;j++){
reader.skip(1);
ch=reader.read();
while ((ch = reader.read()) != '?')
bStrm.write(ch);
String str = new String(bStrm.toByteArray());
pixels[i*160+j] = Integer.parseInt(str);
bw1.write(""+pixels[i*160+j]);
bStrm.reset();
}
bw1.newLine();
}
img.setRGB(0,0,160,120,pixels,0,160);
ImageIO.write(img,"jpg",myfile);
}catch(Exception e){
}
bw1.close();
Etiketler:
j2me,
java servlets,
thesis
how to send image from mobile phone to servlet :Mobile Side
public synchronized void run(){
HttpConnection c = null;
OutputStream os = null;
try{
c = (HttpConnection)Connector.open(url);
// Set the request method and headers
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty("User-Agent",
"Profile/MIDP-2.0 Configuration/CLDC-1.0");
c.setRequestProperty("Content-Language", "en-US");
os = c.openOutputStream();
Image myimage = Image.createImage(imageData,0,imageData.length);
int w = myimage.getWidth();
int h = myimage.getHeight();
DataOutputStream out = new DataOutputStream(os);
System.out.println("width:"+myimage.getWidth());
System.out.println("height:"+myimage.getHeight());
int [] rgbdata = new int[160*120];
System.out.println("length :"+rgbdata.length);
myimage.getRGB(rgbdata, 0, myimage.getWidth(), 0, 0, myimage.getWidth(), myimage.getHeight());
for(int i = 0 ;i LT h;i++){
for(int j=0;j LT w;j++){
out.writeUTF(rgbdata[i*w+j]+"?");
}
}
}
catch(Exception e){
}
}
HttpConnection c = null;
OutputStream os = null;
try{
c = (HttpConnection)Connector.open(url);
// Set the request method and headers
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty("User-Agent",
"Profile/MIDP-2.0 Configuration/CLDC-1.0");
c.setRequestProperty("Content-Language", "en-US");
os = c.openOutputStream();
Image myimage = Image.createImage(imageData,0,imageData.length);
int w = myimage.getWidth();
int h = myimage.getHeight();
DataOutputStream out = new DataOutputStream(os);
System.out.println("width:"+myimage.getWidth());
System.out.println("height:"+myimage.getHeight());
int [] rgbdata = new int[160*120];
System.out.println("length :"+rgbdata.length);
myimage.getRGB(rgbdata, 0, myimage.getWidth(), 0, 0, myimage.getWidth(), myimage.getHeight());
for(int i = 0 ;i LT h;i++){
for(int j=0;j LT w;j++){
out.writeUTF(rgbdata[i*w+j]+"?");
}
}
}
catch(Exception e){
}
}
Etiketler:
j2me,
java servlets,
thesis
Subscribe to:
Posts (Atom)