0

I can't understand the problem im having with PlayN.net. Maybe it's trivial, but since im new to web based stuff, I'm kinda stuck, so I hope someone here can enlighten me :)

My problem: I would like to acess a servlet from my game, it works, but only in java. Html gives me back an empty string.

Simple Servlet:

public class Servlet1 extends HttpServlet {
   protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException
   {
      PrintWriter writer = response.getWriter();
      writer.println("test");
      writer.close();
   }
}

and simple call:

PlayN.net().get("http://localhost:8080/Test", new Callback<String>() {
            @Override
            public void onSuccess(String result) {
                System.out.println("YAY "+result);
            }
            @Override
            public void onFailure(Throwable cause) {
                System.out.println("BUH");
            }
        });

So like I said, java prints "YAY test", HTML prints "YAY" and I cannot figure out why. I tried running the servlet on an other server (not localhost) but the same reaction.

Anyone an idea what I'm doing wrong?

vyegorov
  • 21,787
  • 7
  • 59
  • 73
Andrei
  • 38
  • 2

1 Answers1

0

In the browser (HTML) you have to work with the 'Same origin policy': See http://en.wikipedia.org/wiki/Same_origin_policy

Suggested solutions and work-arounds:

Collaboration from PlayN client with server

Why net().get on success return empty string

Community
  • 1
  • 1