View Full Version : how to create mutilple hessian client?

08-17-2011, 09:59 AM
Hi all,
Look at my code below:
public interface WordService {
* Submits a poem as a List of Words to the service.
public String hello();

public void initWord(String word);
//implement service
public class WordServiceImpl extends HessianServlet implements WordService{
String word;
public String hello() {
return word;

public void initWord(String word) {
this.word = word;
public class WordClient {
/** The client proxy for the WordService. */
private WordService _service;
public WordClient(String url, String word) {
HessianProxyFactory factory = new HessianProxyFactory();
try {
_service = (WordService) factory.create(WordService.class, url);
} catch (MalformedURLException e) {

public void helloClient() {
if(_service != null)

public static void main(String[] args) {
String url = "http://localhost:8080/Word/Word";
WordClient client = new WordClient(url, "Word");
client.helloClient(); //will print Word
WordClient client1 = new WordClient(url, "Word 1");
client.helloClient(); //will print Word 1 ( ->here, I would like to print Word )
client1.helloClient(); //will print Word 1

I mean on client side, if I create multiple client, the last created client will override other clients. I don't know what's wrong?