Wednesday, March 28, 2007

learn some usability

Wednesday, March 21, 2007

writing the image as stream from servlets

You can use the following code to push the image as stream from the server (What if you dont have the image as a file? What if you create an image stream rather than reading an image file?)



HttpServletRequest req = (HttpServletRequest)request;

HttpServletResponse res = (HttpServletResponse)response;



byte[] ba = getImageBytes(); //implement a method to read the image bytes



ServletOutputStream sos = res.getOutputStream();

res.setContentType("image/jpeg"); //give the corresponding image type.

res.setContentLength(ba.length);

sos.write(ba);



This way you can write any no of images as stream to your web page.



/>



powered by performancing firefox

flash java remoting - openamf

would like to connect from flash to java thru http?



the free solution is openamf - www.openamf.com



Adobe has solution for it. It is costly. Adobe even asks so much for support.







powered by performancing firefox

getting the request object parameters in java flash remoting thru openamf



when you use openamf, your java client talks directly to your java classes. that is, you will not use a servlet or jsp to recieve a request or respond.



what will you do if want to recieve any information from the request object?



openamf talks to your server (say tomcat) thru the servlet org.openamf.DefaultGateway (inside openamf.jar - the primary jar file that you need to work with openamf).



openamf is opensource. take the class org.openamf.DefaultGateway.java. here you will get the request object in the service method. You can insert your code here to pass the request object as a parameter to your class' method. compile and recreate openamf.jar. replace with your new openamf.jar. you got your request object. sail happily.



to recieve the request object in my code i do the following



public class RequestObjectGetter

{

private static HttpServletRequest request;



public static void setRequestObject(HttpServletRequest req)

{

request = req;

}



public static HttpServletRequest getRequestObject()

{

return req;

}

}



add code to suit your needs. happy remoting!





powered by performancing firefox

Tuesday, March 20, 2007

zoho creator great!

you would like to conduct a meeting.



not high budgetted?

you have to construct a website to collect registrations etc? no more!



visit www.zohocreator.com (and other zoho sites in www.zoho.com). you can create an online form in minutes, plus you can get free space as well. leaves your hand free in minutes.



go ahead and give yourself a try.



for a sample you can see http://creator.zoho.com/aruljose2/sample-meeting/ .

you can also embed your form just like how you see below any where.







is it not great?

tag completion for xhtml conversion using java

This java class completes the incomplete tags in your html [you need to pass the html as a string to the function convertHtml(String)]. The code is free for use.

First make sure your html is browser compatible, then use this code for tag completion.

import java.util.Stack;

public class HtmlToXHtml
{
public String convertHtml(String fs)
{
StringBuffer nfs = new StringBuffer();
boolean parsingOver = false;
StringBuffer startTag = new StringBuffer();
StringBuffer endTag = new StringBuffer();
StringBuffer currentEndTag = new StringBuffer();

Stack stack = new Stack();

int sl = fs.length();
sl--;

int i=0;

while(!parsingOver)
{
if(i>sl) {parsingOver = true;break;}

if(fs.charAt(i)=='<')
{
//END TAG PART
if(fs.charAt(i+1)=='/')
{
endTag = new StringBuffer(""+fs.charAt(i));
i++;
//System.out.println(i);
while(fs.charAt(i)!= '>')
{
if(fs.charAt(i)=='<')
{
nfs.append(endTag);
break;
}
else if (i>sl)
{
nfs.append(endTag);
parsingOver = true;
break;
}
endTag.append(fs.charAt(i));
//System.out.println("\n CHARACTER : "+fs.charAt(i));
i++;
//System.out.println(i);
if(i>sl){i--; parsingOver=true; break;}
}

if(fs.charAt(i)== '>')
{
endTag.append(fs.charAt(i));
//System.out.println("\n CHARACTER : "+fs.charAt(i));


if(endTag.indexOf(" ")== -1)
{
//System.out.println("\nA END TAG COMING IN : "+endTag);

startTag = new StringBuffer(); //essential for the condition in the next while

try
{
//System.out.println(stack);
startTag = (StringBuffer)stack.pop();
//System.out.println("POPPING START TAG : "+startTag);

while(!(startTag.toString()).equals(getStartTagForEndTag(endTag).toString()))
{
if(i>sl) {parsingOver = true;break;}
//System.out.println("START TAG : "+startTag+" END TAG : "+getStartTagForEndTag(endTag));
currentEndTag = getEndTagForStartTag(startTag);
nfs.append(currentEndTag);
try
{
startTag = (StringBuffer)stack.pop();
//System.out.println("POPPING START TAG : "+startTag);
}
catch(Exception e)
{
nfs.append(getStartTagForEndTag(endTag));
break;
}

}
}
catch(Exception e)
{
nfs.append(getStartTagForEndTag(endTag));
//System.out.println(e);
}

nfs.append(endTag);
i++;
//System.out.println(i);
}
else
{
nfs.append(endTag);
}
}
else
{
nfs.append(endTag);
}
}


//STARTING TAG PART
else if (fs.charAt(i+1)!=' ')
{
startTag = new StringBuffer(""+fs.charAt(i));
i++;
System.out.println(i+" : "+nfs );
while(fs.charAt(i)!= '>')
{
if(i>sl) {parsingOver = true;break;}
if(fs.charAt(i)=='<')
{
break;
}
startTag.append(fs.charAt(i));
i++;
if(i>sl){i--; parsingOver=true; break;}
}
if(fs.charAt(i)== '>')
{
startTag.append(fs.charAt(i));
nfs.append(startTag);

if((startTag.indexOf(" ")== -1)||(startTag.indexOf(" ")>1))
{
StringBuffer startTagPart = new StringBuffer();
if(startTag.indexOf(" ")>1)
{
startTagPart = new StringBuffer(startTag.substring(0,startTag.indexOf(" "))).append(""+'>');
}
else startTagPart = new StringBuffer(startTag);
stack.push(startTagPart);
}

i++;
}
else
{
nfs.append(startTag);
}
}
}
else
{
nfs.append(fs.charAt(i));
//System.out.println("\n CHARACTER1 : "+fs.charAt(i));
i++;
//System.out.println(i);
}
}

while(!stack.empty())
{
try
{
startTag = (StringBuffer)stack.pop();
//System.out.println("POPPING START TAG : "+startTag);
currentEndTag = getEndTagForStartTag(startTag);
nfs.append(currentEndTag);
}
catch(Exception e)
{
break;
}
}

return nfs.toString();
}


private StringBuffer getEndTagForStartTag(StringBuffer startTag)
{
StringBuffer startTag1 = new StringBuffer(startTag);
return startTag1.insert(1, '/');
}

private StringBuffer getStartTagForEndTag(StringBuffer endTag)
{
StringBuffer endTag1 = new StringBuffer(endTag);
endTag1.replace(1,2,"");
return endTag1;
}

}

Sunday, March 4, 2007

social wrapper and login page

Social wrapper is the one which makes the site a good web 2.0 - the one's which shows you the latest, popular, most viewed, most commented, most replied stuff (etc) in the site.



This increases the interaction between the creators and the viewers and thus welcomes the viewers again and again to the same site (gives a good traffic).



This becoming a very popular concept in the web world all the sites are trying to bring this in.



I suggest it would be great to show your social wrapper right in the front page. Users should be able to touch the social wrapper without having to login. Show the wrapper right in your home page (see www.slideshare.net for example).



Let not your login tab (the space you use for your login - username and password) take too much of space. finish them in one line if possible - ajax can help.



best of luck for your new web2.0 site.



thinking of a building a new web2.0 site? Analyse your needs before you start. Hope this can help you start your analysing.