android 에서 값을 jsp 로 넘겨주고 싶은데요
android 태아 수준이라 질문이 어이가 없어도 이해해주세요 ^.^;;
MainAcrivity에서
private void write(){
try{
HttpClient client = new DefaultHttpClient();
String getURL = url;
HttpPost post = new HttpPost(getURL);
List params = new ArrayList();
params.add(new BasicNameValuePair("id", id));
params.add(new BasicNameValuePair("pass", pass));
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,HTTP.UTF_8);
post.setEntity(ent);
HttpResponse responseGET = client.execute(post);
HttpEntity resEntity = responseGET.getEntity();
if(resEntity != null){
Log.w("RESPONSE",EntityUtils.toString(resEntity));
}
}
catch(Exception e){
}
}
(블로그에서.. 가져온 소스입니당..ㅠ )
Log를 찍어보면
라고 잘 찍혀나오는데
jsp실행시켜보면 계속 null이 떨어지네요.
제가 뭘 빼먹고 가고 있는지 좀 알이켜주세요 T.T
insert.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script>
window.setTimeout('window.location.reload()',1000); // 1000초당 1초
</script>
</head>
<body>
<%
String id = request.getParameter("id");
String pass = request.getParameter("pass");
out.print("id : " + id);
out.print(" password : " + pass);
%>
가나다라
id text = <input type="text" name="id">
pass text = <input type="text" name="pass">
<p />
id = <%= id %>
</body>
</html>
request.getParameter("id");는 해당 페이지를 요청할때 파라미터로 id값을 보냈을 경우에만 null이 아닌 값을 반환합니다.
브라우져에서 jsp를 호출할때 id와 pass를 파라미터로 같이 넣었는지 확인해보세요.
안드로이드에서는 저값을 보냈기 때문에 로그에 보내신 값이 그대로 찍히는거같아 보이구요.
브라우져에서는 값을 보내지 않아 null이 찍히는 것으로 보입니다.
jsp뒤에 ?id=iddd&pass=passww 를 더붙여서 해보세요.