Feed on
 Posts
 Comments
Java Beans dot Asia

Just a few simple tutorials …

I wanted to start a discussion what is the better choice for an application server when building an enterprise J2E application? Should one go for a Tomcat + Spring combination which provide light-weight simplified [...] Continue Reading…

GD Star Rating
loading...

In this example I would like to show how unmarshall XML into a POJO using HierarchicalStreamReader. I will introduce how to use  XStream and a custom XML-to-POJO converter, describe a case study and develop [...] Continue Reading…

GD Star Rating
loading...

I got a new Dell Latitude e6410 from work. After trying Windows it for a few days, I decided to get back to Ubuntu, since I really prefer developing on Linux.

Unfortunately, after booting from [...] Continue Reading…

GD Star Rating
loading...

I came across a video called Java 4-Ever Trailer. Produced by guys at Java Zone.  Its a trailer about supposedly upcoming movie about an average family living in .NET world.  Their son grows up [...] Continue Reading…

GD Star Rating
loading...

在这篇文章中,我想说明如何的JSON(JavaScript对象
符号)和Java Servlet可以同时使用在一个小的AJAX((Asynchronous JavaScript and XML)的应用。

为了作简要介绍那些谁不熟悉使用JSON密切。JSON是一种表示数据,这使得工作轻量级语法
它比更愉快,使AJAX应用程序的XML 快。此外,当使用JSON工作,没有任何一个XML需要
解析。

在下面的例子,我将创建一个回调的servlet 获取并分析了RSS提要。然后解析数据被传递到饲料
在一个客户端JSON的形式。这些数据然后格式化并提交 给用户。客户端使用AJAX调用来查询的servlet。

对于这种应用,我使用了三个第三方库:

图书馆提供的JSON和JSON的JSON.org – RPC的Java的,允许以建立并轻松地通过Java代码解析JSON数据延长。该库可以运行在一个如Tomcat,JBoss和其他J2EE应用服务器的Servlet容器。

项目罗马
罗马是一个开放源码的Java工具,用于分析,生成和发布RSS和Atom馈送。

JDOM的XML解析器
JDOM是一个基于Java的“文档对象模型的XML文件”。 JDOM的服务作为DOM的相同目的,但更容易使用

这些库中包含的源代码,附带这篇文章。此应用程序的例子还包括作为一个WAR档案,随时可以在Tomcat部署。
以下是我的servlet实现。该servlet饲料获取并分析数据。前面提到的JSON库让我轻松地创建和填充JSON对象。

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
import org.json.JSONObject;

import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.fetcher.FeedFetcher;
import com.sun.syndication.fetcher.FetcherException;
import com.sun.syndication.fetcher.impl.FeedFetcherCache;
import com.sun.syndication.fetcher.impl.HashMapFeedInfoCache;
import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;
import com.sun.syndication.io.FeedException;

/**
* @author Alexander Zagniotov (http://javabeans.asia)
*/
public class JsonServlet extends HttpServlet {

private static final long serialVersionUID = 1L;
private [...] Continue Reading…

GD Star Rating
loading...

Page 1 of 151234510...Last »