如何从谷歌应用程序引擎调用我的应用程序的URL [英] How to call my app url from google app engine

查看:147
本文介绍了如何从谷歌应用程序引擎调用我的应用程序的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Java GWT开发了我的应用程序,并在Google应用程序引擎上部署了我的应用程序。我的访问网址是sample.myappid.appspot.com我想通过代码调用这个URL,所以我喜欢这样: - $ / $>

 网址; 
尝试{
url =新网址(http://sample.myappid.appspot.com);

HttpURLConnection连接=(HttpURLConnection)url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod(POST);


if(connection.getResponseCode()== HttpURLConnection.HTTP_OK){
// OK
logger.log(Level.SEVERE,完成okkkkkk) ;
} else {
//服务器返回HTTP错误代码。
logger.log(Level.SEVERE,Erorrrrrr);
}

} catch(Exception e1){
// TODO自动生成的catch块
e1.printStackTrace();
}

这不会调用我的网址。所以任何其他的解决方案,我怎么能调用我的网址使用代码。



任何帮助?

解决方案

如果/从应用程序的请求处理程序请求应用程序时,您需要注意,因为您可能会导致无限递归循环,使GAE尝试产生新的应用程序实例,这样的请求。可能与您的其他问题有关:,而用户不活动2分钟获取信息此请求导致为您的应用程序启动一个新进程



在内部基本上向您的应用程序的服务命名空间中的路径发出请求(例如 /index.html ):





这些内部方法发起的请求是inter最终生成,独立于外部请求,并且可以安全地用于实现您的应用程序的逻辑(如果误用,循环仍然可行,但仅创建大量活动,它们不是无限重置/死锁,因为强制GAE为每个请求产生一个新实例)。



您也可以使用通用的URL访问(适用于任何URL,不仅适用于您的应用),就像外部用户将访问您的应用程序。这些可以用于自动测试你的应用程序,但是请注意,它们可能比内部访问方法更昂贵,我不会推荐它们实际实现你的应用程序的逻辑:




  • 使用网址提取API

  • 使用java.net



这些外部访问方法也会遇到无限递归问题,因此请小心使用它们。


I developed my application using java GWT and I deployed my application on google app engine. my access url is sample.myappid.appspot.com I want to call this url through code so i did like this :-

  URL url;
            try {
                url = new URL("http://sample.myappid.appspot.com");

            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setDoOutput(true);
            connection.setRequestMethod("POST");


            if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                // OK
                logger.log(Level.SEVERE,"Done okkkkkk");
            } else {
                // Server returned HTTP error code.
                logger.log(Level.SEVERE,"Erorrrrrrr");
            }

            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }  

This is not calling my url. so any other solution how can i call my url using code.

Any help?

解决方案

You need to pay attention if/when making requests to your app right from inside your apps' request handlers as you can cause infinite recursive loops, making GAE attempt to spawn a new app instance in an attempt to serve each such request. Possibly related to your other question: while user inactivity of 2mins getting info "This request caused a new process to be started for your application".

There are several methods to access your app programatically from itself, internally, basically making requests to paths in your app's serving namespace (like /index.html, for example):

Requests initiated by these internal methods are internally generated, independent of external requests, and can be safely used to implement your app's logic (loops are still possible if misused, but only creating a great deal of activity, they're not infinite recusions/deadlocking in the sense of forcing GAE to spawn a new instance for every request).

You can also use generic URL access from your app (applicable to any URL, not only those of your app), just as an external user would access your app. These can be useful for automated testing of your app, but note that they can be more costly than the internal access methods, I wouldn't recommend them for actually implementing your app's logic:

These external access methods are also subject to infinite recursion problem, so use them with care.

这篇关于如何从谷歌应用程序引擎调用我的应用程序的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆