안드로이드 (갤스) 에서  4개의 에디트텍스트를 이용해 jsp 로 데이터를 전송해 보았습니다


name = ((EditText)(findViewById(R.id.regist_Name_Edit))).getText().toString();
    price = ((EditText)(findViewById(R.id.regist_Price_Edit))).getText().toString();
    market = ((EditText)(findViewById(R.id.regist_Market_Edit))).getText().toString();
    location = ((EditText)(findViewById(R.id.regist_location_Edit))).getText().toString(); 


jsp 서버에서 받은 데이터를 찍어 보았더니 잘 찍힙니다

 

 <% System.out.println("클라이언트로부터 데이터 받음 ");  %>
  <% String s1 = request.getParameter("name"); %>
  <% String s2 = request.getParameter("price"); %>
  <% String s3 = request.getParameter("market"); %>
  <% String s4 = request.getParameter("location"); %>
   
  <% System.out.println("name="+s1);  %>
  <% System.out.println("price="+s2);  %>
  <% System.out.println("market="+s3);  %>
  <% System.out.println("location="+s4);  %>


콘솔창


name=a
price=1000
market= 특수문자 한글깨짐         < ---  한글은 깨져서 오는군요 수정 방법좀 알려주세요               
location=k
name=a

 


하지만 이 받은 데이터를 db 에 저장하려하는데


일단 테이블을 하나 만들고 받은 데이터 s1을  다시 찍어보니  null 값이 나오네요     s1 = name


캡처화면 있어요


 <table width="100%" border="0" cellspacing="1" cellpadding="5">
   <tr>
    <td width="150" align=center class="txt_pro" nowrap
     bgcolor="#faf7f0">제품명</td>
    <td width="500" bgcolor="#FFFFFF">
     <table cellpadding=0 cellspacing=0>
      <tr>
       <td><input type=text size=10 name="name" class="input01" value="<%=s1%>">
       </td>
       <td><%= s1 %></td>
      </tr>
     </table>
<!-- 제품종류 -->


생각해보니 안드로이드에서 jsp 서버로 보낸 데이터는 찍히지만 이 받은 데이터를 db 에 보내려고하면


받은데이터가 소멸되는거같아요..


이데이터를 살려줘야 db에 집어넣을수가 있는데요..


고수님들 알려주세요 ㅠㅠ


주요 소스


-------------------------------------안드로이드------------------------------------------

regist_Button.setOnClickListener(new OnClickListener() {
  
   @Override
   public void onClick(View v) {
   
   
    name = ((EditText)(findViewById(R.id.regist_Name_Edit))).getText().toString();
    price = ((EditText)(findViewById(R.id.regist_Price_Edit))).getText().toString();
    market = ((EditText)(findViewById(R.id.regist_Market_Edit))).getText().toString();
    location = ((EditText)(findViewById(R.id.regist_location_Edit))).getText().toString();  
   
   
   
    // TODO Auto-generated method stub
    HttpPostData();
   
   
    reRegistDialog();
    dbmgr.UpdateDB(name_Edit.getText().toString(), price_Edit.getText().toString(),
      market_Edit.getText().toString(), location_Edit.getText().toString());
  
   }
  });
 }
 
    public void HttpPostData() {
        try {
             //--------------------------
             //   URL 설정하고 접속하기
             //--------------------------
             URL url = new URL("http://192.168.123.111:8080/strutsIbatis/basket/productAdd.jsp?name="+name+"&price="+price+"&market="+market+"&location="+location);       // URL 설정
             HttpURLConnection http = (HttpURLConnection) url.openConnection();   // 접속
             //--------------------------
             //   전송 모드 설정 - 기본적인 설정이다    "login.jsp?name=value&price=value&id=value
             //--------------------------
             http.setDefaultUseCaches(false);                                           
             http.setDoInput(true);                         // 서버에서 읽기 모드 지정
             http.setDoOutput(true);                       // 서버로 쓰기 모드 지정 
             http.setRequestMethod("POST");         // 전송 방식은 POST

             // 서버에게 웹에서 <Form>으로 값이 넘어온 것과 같은 방식으로 처리하라는 걸 알려준다
             http.setRequestProperty("content-type", "application/x-www-form-urlencoded");
             //--------------------------
             //   서버로 값 전송
             //--------------------------
             StringBuffer buffer = new StringBuffer();
             buffer.append("id").append("=").append(name).append("&");              
             buffer.append("price").append("=").append(price).append("&");  
             buffer.append("market").append("=").append(market).append("&");           // 변수 구분은 '&' 사용 
             buffer.append("location").append("=").append(location);
            Log.d("name=" , name);
             OutputStreamWriter outStream = new OutputStreamWriter(http.getOutputStream(), "EUC-KR");
             PrintWriter writer = new PrintWriter(outStream);
             writer.write(buffer.toString());
             writer.flush();
             //--------------------------
             //   서버에서 전송받기
             //--------------------------
             InputStreamReader tmp = new InputStreamReader(http.getInputStream(), "EUC-KR"); 
             BufferedReader reader = new BufferedReader(tmp);
             StringBuilder builder = new StringBuilder();
             String str;
             while ((str = reader.readLine()) != null) {       // 서버에서 라인단위로 보내줄 것이므로 라인단위로 읽는다
                  builder.append(str + "\n");                     // View에 표시하기 위해 라인 구분자 추가
             }
             myResult = builder.toString();                       // 전송결과를 전역 변수에 저장
           // ((TextView)(findViewById(R.id.text_result))).setText(myResult);
            //Toast.makeText(jwUpdateInput.this, "전송 후 결과 받음", 0).show();
        } catch (MalformedURLException e) {
               //
        } catch (IOException e) {
               // 
        } // try
   } // HttpPostData
 // Activity

 

 

 

------------------jsp 서버 --------------------------------

 

<%@ page language="java" contentType="text/html; charset=EUC-KR"
 pageEncoding="EUC-KR"%>
<!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=EUC-KR">
<title>Insert title here</title>
</head>
<body>
   
 <h1 align="center">ProductAdd</h1>
  <!-- multipart/form-data 이걸주면 텍스하고 바이너리 같이 넘어간다 -->

<!-- 제품명 -->

 <form action="productAdd.do" name="frm" method="post"
  enctype="multipart/form-data">
  <% System.out.println("클라이언트로부터 데이터 받음 ");  %>
  <% String s1 = request.getParameter("name"); %>
  <% String s2 = request.getParameter("price"); %>
  <% String s3 = request.getParameter("market"); %>
  <% String s4 = request.getParameter("location"); %>
   
  <% System.out.println("name="+s1);  %>
  <% System.out.println("price="+s2);  %>
  <% System.out.println("market="+s3);  %>
  <% System.out.println("location="+s4);  %>
 

  <table width="100%" border="0" cellspacing="1" cellpadding="5">
   <tr>
    <td width="150" align=center class="txt_pro" nowrap
     bgcolor="#faf7f0">제품명</td>
    <td width="500" bgcolor="#FFFFFF">
     <table cellpadding=0 cellspacing=0>
      <tr>
       <td><input type=text size=10 name="name" class="input01" value="<%=s1%>">
       </td>
       <td><%= s1 %></td>
      </tr>
     </table>
<!-- 제품종류 -->