2011-09-12 6 views
0

필자는 filewriting을 위해 서버에 연결하고있는 애플릿을 가지고 있습니다. localhost를 사용하여 서버에 연결하려고하면 : 내 컴퓨터에서 작동하지만 (서버가 동일한 컴퓨터에 있음) 작동하지 않습니다. 다른 기계. 내가 IP 주소로 할 때애플릿 액세스 제어 문제

그것은 더 작동없는 경우

내 애플릿 코드 :

public class dynamicTreeApplet extends JPrefuseApplet { 

    private static final long serialVersionUID = 1L; 
    public static int i = 1; 
    public String dieasenameencode; 
    public void init() { 

     System.out.println("the value of i is " + i); 
     URL url = null; 
     //Here dieasesname is important to make the page refresh happen 

     //String dencode = dieasenameencode.trim(); 
     try { 
      //String dieasename = URLEncoder.encode(dencode, "UTF-8"); 
      // i want this piece of the code to be called 
      url = new URL("http://localhost:8080/docRuleTool/appletRefreshAction.do?dieasename="); 
      URLConnection con = url.openConnection(); 
      con.setDoOutput(true); 
      con.setDoInput(true); 
      con.setUseCaches(false); 
      InputStream ois = con.getInputStream(); 
      this.setContentPane(dynamicView.demo(ois, "name")); 
      ois.close(); 

     } catch (MalformedURLException e) { 
      e.printStackTrace(); 
     } catch (FileNotFoundException f) { 
      f.printStackTrace(); 

     } catch (IOException io) { 
      io.printStackTrace(); 
     } 
     ++i; 
    } 

} 

자바 정책 파일 :

grant { 
    permission java.net.SocketPermission "*", "accept"; 
    permission java.net.SocketPermission "*", "connect"; 
}; 

내 항아리에 서명하고 난 그들을 원하는이 donot되지 않습니다 유지의 관점에서 서명되어야한다.

+0

내 질문에 아무런 의미가 없습니다 – bhalkian

+1

30 분 이내에 질문에 대한 답변을 얻지 못할 경우 걱정하지 마십시오. –

답변

3

내 컴퓨터 (서버가 동일한 시스템에있는)에서 작동하지만, 다른 기계

예에 대한 작업을 doesnot하지만 정말 단지 '다른 시스템'에서 제공되는 애플릿 의미가 있습니다 다른 컴퓨터에 다시 쓰는 것입니다. 위의 코드는 .. 다른 호스트에서 오는 애플릿이 다시 아마 존재하지 않는 '로컬 호스트'에 데이터를 기록하려고 시도하는 것을 의미

url = new URL("http://localhost:8080/docRuleTool/appletRefreshAction.do?dieasename="); 

있습니다. 대신, 애플릿이 코드는 할 수 있어야한다는 않으면 ..

url = new URL(getDocumentBase(), "/docRuleTool/appletRefreshAction.do?dieasename="); 

을의 라인을 따라 뭔가 더를 사용하여 URL을 형성 남아 있어야 모래 박스.


정책 파일은 실제로 개발 목적으로 만 사용됩니다. 실제 배포시 코드가 신뢰를 필요로하는 경우 디지털 서명이 필요합니다.