URL을

2012-09-12 2 views
0

내가 같은 URL에 게시 서명 자바 애플릿을 사용하려고의 쿼리 부분에는 urlencoding없이 자바로 작성하는 방법 :URL을

http://some.domain.com/something/script.asp?param=5041414F9015496EA699F3D2DBAB4AC2|178411|163843|557|1|1|164||attempt|1630315

그러나 자바는 연결, 자바 콘솔 프로그램을 할 때 :

네트워크 : 나는 자바에서 쿼리에 파이프를 urlencode 싶지 않아 http://some.domain.com/something/script.asp?param=5041414F9015496EA699F3D2DBAB4AC2%7C178411%7C163843%7C557%7C1%7C1%7C164%7C%7Cattempt%7C1630315

연결 | ~ % 7c. 내가 연결하고있는 서비스가 param을 urldecode하지 않는 것 같아서 서버 측 코드를 변경할 수 없습니다. 자바에서 쿼리를 이스케이프하지 않고 게시물을 만들 수있는 방법이 있습니까?

내가 사용 자바는 다음과 같습니다 :

try { 
     URL url = new URL(myURL); 
     URLConnection connection = url.openConnection(); 
     connection.setDoOutput(true); 

     OutputStreamWriter out = new OutputStreamWriter(
       connection.getOutputStream()); 
     out.write(toSend); 
     out.close(); 

     BufferedReader in = new BufferedReader(
       new InputStreamReader(
         connection.getInputStream())); 

     String decodedString = ""; 

     while ((decodedString = in.readLine()) != null) { 
      totalResponse = totalResponse + decodedString; 
     } 
     in.close(); 

    } catch (Exception ex) { 
    } 

어떤 도움 주셔서 감사합니다!

+0

"URL 인코딩/urldecoding"- HTTP 프로토콜의 일부입니다. 연결하는 서비스가 urldecoding을하지 않더라도,'param'에서 원시 5041414F9015496EA699F3D2DBAB4AC2 | 178411 | 163843 | 557 | 1 | 1 | 164 || 시도 | 1630315'을 얻어야합니다. – michael

+1

URL 클래스가 어떤 인코딩도하지 않습니다. 당신의 코드가'new URL()'을 호출하기 전에'myURL'을 조작하지 않았다고 확신합니까? – jtahlborn

+0

myURL == http://some.domain.com/something/script.asp?param=5041414F9015496EA699F3D2DBAB4AC2|178411|163843|557|1|1|164||attempt|1630315 자바 콘솔에 있습니다. : 네트워크 : http://some.domain.com/something/script.asp?param=5041414F9015496EA699F3D2DBAB4AC2%7C178411%7C163843%7C557%7C1%7C1%7C164%7C%7Cattempt%7C1630315 프록시 = HTTP @ localhost/127.0 연결 .0.1 : 8888 – RouterBox

답변

0

URL 클래스는 인코딩을 수행하지 않습니다. 내 dev에 서버 테스트이 의심을 확인했다. 귀하의 코드는 귀하의 질문에 포함 된 스니피트 앞에 어딘가에 '|' 문자를 인코딩해야합니다.

+0

테스트 도중 자바 콘솔을 보았다면, 생성 된 network : 행에 urlencoded로 표시됩니까? – RouterBox

+0

@RouterBox - 아니요, 확인을 위해 프록시를 통해 전화를 걸었습니다. – jtahlborn

+0

도움 주셔서 감사합니다. – RouterBox

관련 문제