[英]How to Authenticate android app with tomcat sever?
I am working on an application where I want to send an HTTP post to my Tomcat sever. 我正在开发一个应用程序,该应用程序要将HTTP帖子发送到Tomcat服务器。 In this post,I want to send the user-id as well as password and after successful authentication from TomCat it will respose to my app, II want next-page to display in my emulator? 在这篇文章中,我想发送用户ID和密码,并且从TomCat成功进行身份验证后,它将重新放置到我的应用程序中,我想让下一页显示在模拟器中吗? Any procedure or framework on this aspect ...that I have to use. 我必须使用的有关此方面的任何过程或框架。
I am posting the code to post the request and get response. 我正在发布代码以发布请求并获得响应。
public class Register extends Activity
{
public static final String PREFS_NAME = "LoginPrefs";
public static final String USER_NAME = "USER";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.register);
TextView txt = (TextView) findViewById(R.id.textView1);
txt.setText(getPage());
}
private String getPage()
{
String str = "***";
try
{
HttpClient hc = new DefaultHttpClient();
HttpPost post = new HttpPost("http://www.yahoo.com");
HttpResponse rp = hc.execute(post);
if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
str = EntityUtils.toString(rp.getEntity());
}
}catch(IOException e){
e.printStackTrace();
}
return str;
}
}
Now u help me with how to send data with request and server will check the incoming data if data is present in database that will ensure that user is a valid user and send some response depending on that response i will navigate to next page. 现在,您可以通过请求发送数据,服务器会检查传入的数据(如果数据库中存在数据),以确保用户是有效用户,并根据该响应发送一些响应,我将导航至下一页。 How will do this? 怎么做? Please help since i am new to java and android. 请帮助,因为我是Java和android的新手。
看看这里的google搜索的第一个回复
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.