开发者

java servlets response - stay on same page

开发者 https://www.devze.com 2023-01-23 02:46 出处:网络
Hi I call Java servlet using flash navig开发者_C百科ateToURL method. In some cases I want the servlet to tell the browser client to stay on the same page - How can I achieve that? If the response is

Hi I call Java servlet using flash navig开发者_C百科ateToURL method.

In some cases I want the servlet to tell the browser client to stay on the same page - How can I achieve that? If the response is empty than the page becomes blank.


I think you are using the wrong method to access java servlets. If you need to keep the same page open, navigateToURL is not what you should use. nagivateToURL method is as per the documentation:

Opens or replaces a window in the application that contains the Flash Player container (usually a browser). In Adobe AIR, the function opens a URL in the default system web browser

You can use

  1. Flash Remoting APIs for calling servlets
  2. HttpService
  3. URLRequest method.

Check the links for more details.


You can't. navigateToURL instructs the browser to open another URL. The content is fetched after the browser navigation changes.

You should make an HTTP request within the flex app. This can be done like this:

var req:URLRequest = new URLRequest();
req.method = URLRequestMethod.POST;
var vars:URLVariables = new URLVariables();
vars.param1 = "param1";
vars.param2 = "param2";
req.data = vars;
req.url = "/targetUrl";

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, pageLoadComplete);
loader.load(req);

And then in the pageLoadComplete(event:Event) method:

var result:String = URLLoader(event.currentTarget).data.toString();

It is advisable to make such a call to a URL that returns simply true or false, depending on whether you will have to redirect or not.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号