Tuesday, May 20, 2008
Tuesday, May 13, 2008
How to twitter from JSP
As per Twitter API in order to post new twit from the application you have to perform HTTP POST request to the following URL: http://twitter.com/statuses/update.xml
See how to do that easily with HTTP taglib from Coldtags suite:
<%@ taglib uri="taglib32.tld" prefix="t" %>
<t:GetPost url="http://twitter.com/statuses/update.xml" method="post">
<t:setAuthorization user="your_twitter_name"
password="your_twitter_password"/>
<t:setParam name="status">test from JSP</t:setParam>
</t:GetPost>
tag setAuthorization defines a BASIC authentication scheme, so you have just provide here your twitter name and password. Tag setParam defines here
a parameter status (as per API requirements) with your message. So now you can post to twitter right from your JSP pages.
See how to do that easily with HTTP taglib from Coldtags suite:
<%@ taglib uri="taglib32.tld" prefix="t" %>
<t:GetPost url="http://twitter.com/statuses/update.xml" method="post">
<t:setAuthorization user="your_twitter_name"
password="your_twitter_password"/>
<t:setParam name="status">test from JSP</t:setParam>
</t:GetPost>
tag setAuthorization defines a BASIC authentication scheme, so you have just provide here your twitter name and password. Tag setParam defines here
a parameter status (as per API requirements) with your message. So now you can post to twitter right from your JSP pages.
Wednesday, May 07, 2008
Images cache
One useful trick with Expires filter. This filter lets you set Expires and Cache-Control headers for the serviced responses. By this way your web application may deploy client-side cache for the requested resources. For example, you may decide cache all the requested images on the client's box. So for the sub sequential requests images will be served from right the local computer, and your own server will be free from this task. This simple idea lets actually save a lot of server's resources. How does it work:
1. Describe Expires filter in your web.xml file. An initial parameter expires sets here ttl for cache in seconds (24 hours in this example):
<filter>
<filter-name>ExpiresFilter</filter-name>
<filter-class>com.cj.expire.ExpiresFilter</filter-class>
<init-param>
<param-name>expires</param-name>
<param-value>86400</param-value>
</init-param>
</filter>
2. Set a mapping.
<filter-mapping>
<filter-name>ExpiresFilter</filter-name>
<url-pattern>*.gif</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ExpiresFilter</filter-name>
<url-pattern>*.jpg</url-pattern>
</filter-mapping>
...
Now the mapped files (gif, png etc.) will be cached on the client side
1. Describe Expires filter in your web.xml file. An initial parameter expires sets here ttl for cache in seconds (24 hours in this example):
<filter>
<filter-name>ExpiresFilter</filter-name>
<filter-class>com.cj.expire.ExpiresFilter</filter-class>
<init-param>
<param-name>expires</param-name>
<param-value>86400</param-value>
</init-param>
</filter>
2. Set a mapping.
<filter-mapping>
<filter-name>ExpiresFilter</filter-name>
<url-pattern>*.gif</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ExpiresFilter</filter-name>
<url-pattern>*.jpg</url-pattern>
</filter-mapping>
...
Now the mapped files (gif, png etc.) will be cached on the client side
Saturday, April 26, 2008
YouTube and JSP
A simple solution for dealing with YouTube API right from your JSP (or Coldfusion) pages: YouTube mashup taglib. And this article can give you more examples: Use the YouTube API with JSP
Thursday, April 17, 2008
Coldtags suite ver. 3.35
The latest news from Coldtags suite - version 3.35 is ready. From the newest components check out for example Embed download taglib. Now you can download files from any place on your page. You do not need more a separate download page/download servlet. Just add a download code to any of your pages (even the several downloading from one page is Ok).
Labels: Coldtags
Sunday, April 06, 2008
Google Analytics
Check our Google Analytics automation component: Urchin filter. The idea is transparent: add tracking code for the requested pages on the fly.
Labels: JSOS
