Friday, October 21, 2011

Add Twitter to your webpage , Display Tweets using Java script

No comments:
Hi, Everyone like to display tweets on their webpage. Twitter api  provides the way to do it..
All you need to do is trigger a event in java script which retrives last 20 tweets. We can get tweets in two format xml and Json.. I prefer JSON which is very easy to use. I have used JSON. when page is loaed $.getJSON method is called and parameter is passed. i am parsing the return json data and appending it to the div element which shows all tweets.

But the problem is you can not refresh the page many times . i think 3 or 4 .. if u refresh more than 3 to 4 times. .Twitter server denies your request. You have to wait for some more time(Minimum 5 min. Not sure).. To avoid these kind of problem my solution would be to store values in cookies or in session... 

 <script type="text/javascript">
$(document).ready(function() {
    $.getJSON("http://twitter.com/statuses/user_timeline/kaleeswaran14.json?callback=?", function(data) {
    for(i in data) {
        $('.scroll-hold').append('<div class="blog_twit"><div class="blog_twit_img"><img src="images/right1.png" border="0" alt="image"></div><div class="blog_twit_txt">'+data[i].text+'</div><div class="blog_twit_boder">'+parseTwitterDate(data[i].created_at)+'</div></div>');
    }               
    });
    });

function parseTwitterDate($stamp)
{       
    var date = $stamp;   
    return date.substr(0,16);
}
</script>


--
Thank you.


Regards,
Kaleeswaran.S

Read More

Wednesday, October 12, 2011

Maven Hectic Work...

No comments:
I am developing web applications using maven... As a developer cleaning,building, stoping tomcat, placing war file, starting tomcat and opening browser takes 50% time in  a day.. Mostly coding wont take that much time. Each time ill make change i have to build,copy etc...

I love developing But these kind of hectic work make me feel lazy...

Hurray.. !!!

I found a solution for this... BATCH file..

I created a batch file which does all my work.. i am free.. What i have to do is .. Type coding Run the batch file and see the changes.. Sounds nice..

My code is...


@ECHO off
cls
:start
ECHO.
ECHO 1. Install
ProjName1
ECHO 2. Buid ProjName2
ECHO 3. Buid ProjName3
ECHO 4. Delete Files In Tomcat
ECHO 5. Copy Files To tomcat
ECHO 6. Start tomcat
ECHO 7. Stop tomcat
ECHO 8. Run
ProjName
ECHO 9. Exit
set /p choice=Type your choice.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto
ProjName1
if '%choice%'=='2' goto ProjName2
if '%choice%'=='3' goto ProjName3
if '%choice%'=='4' goto delete
if '%choice%'=='5' goto copy
if '%choice%'=='6' goto runtomcat
if '%choice%'=='7' goto stoptomcat
if '%choice%'=='8' goto Run
if '%choice%'=='9' goto end
ECHO "%choice%" is not valid please try again
ECHO.
goto start


:
ProjName1
ECHO Going to Build and Install ProjName
ECHO Please Wait..............
CD /D D:\
ProjName\trunk\ProjName
call mvn clean install

ECHO Shall i proceed ???
PAUSE

goto start


:
ProjName2
ECHO Going to Build ProjName
ECHO Please Wait..............
CD /D D:\
ProjName\trunk\ProjName
call mvn clean package

ECHO Shall i proceed ???
PAUSE

goto start


:
ProjName3
ECHO Going to Build ProjName
ECHO Please Wait..............
CD /D D:\
ProjName\trunk\server\ProjName
call mvn clean package

ECHO Shall i proceed ???
PAUSE


goto start

:delete

ECHO Going to Delete Existing files in tomcat
ECHO Please Wait..............

DEL C:\apache-tomcat-7.0.14\apache-tomcat-7.0.14\webapps\*.war
rmdir /s /q "C:\apache-tomcat-7.0.14\apache-tomcat-7.0.14\webapps\
ProjName"
rmdir /s /q "C:\apache-tomcat-7.0.14\apache-tomcat-7.0.14\webapps\
ProjName"
goto start

:copy
ECHO Going to Copy war files to tomcat
xcopy /s D:\ProjName\trunk\server\engine\target\ProjName.war C:\apache-tomcat-7.0.14\webapps
xcopy /s D:\
ProjName\trunk\framework\target\ProjName.war C:\apache-tomcat-7.0.14\webapps
goto start

:runtomcat

ECHO Going to start tomcat
call "C:\apache-tomcat-7.0.14\bin\startup.bat"
goto start

:stoptomcat

ECHO Going to stop tomcat
call "C:\apache-tomcat-7.0.14\bin\shutdown.bat"
goto start


:run

ECHO Going to open firefox browser with URL
start /d "C:\Program Files\Mozilla Firefox" firefox.exe http://localhost:8080/ProjName
goto end

:end
pause
exit


Happy Coding :)

Read More

Thursday, October 6, 2011

How to Read a XML file From Nexus repository

No comments:
Here I am using the jsersey client library to read xml file from nexus

Specify the URL of the XML

        String BASE_URI = "http://localhost:8080/Nexus";
        WebResource r = c.resource(BASE_URI);
        ClientResponse response = r.get(ClientResponse.class);
        System.out.println( response.getStatus() );
        System.out.println( response.getHeaders().get("Content-Type") );
        String   = response.getEntity(String.class);
        System.out.println(entity);

Thats Done.. It ll display the All XML contents.. 


--
Thank you.


Regards,
Kaleeswaran.S

Read More

Jersey Client API

No comments:
Jersey Client API Implementation And Converting JSON String to object

Jersey Client API code receives json data from web service and converts received jason data to the corresponding object ..

Here the code goes .. 


Read More