scriptlet code을 JSF 클래스로 변환하려고합니다.스크립틀릿에서 JSF 관리 Bean으로 변환 문제
뷰 코드
<f:view>
<h:form binding="#{jsfSocketClient.form}">
<h:outputText binding="#{jsfSocketClient.text}"/>
</h:form>
</f:view>
내가 스크립틀릿 코드를 실행하면, 내가 로 답을 얻고
private HtmlForm form = new HtmlForm();
private HtmlOutputText text = new HtmlOutputText();
public HtmlForm getForm()
{
System.out.println("instance: "+FacesContext.getCurrentInstance().getResponseWriter());
ResponseWriter writer = (FacesContext.getCurrentInstance()).getResponseWriter();
try{
int character;
Socket socket = new Socket("127.0.0.1", 8765);
InputStream inSocket = socket.getInputStream();
OutputStream outSocket = socket.getOutputStream();
String str = "Hello!\n";
byte buffer[] = str.getBytes();
outSocket.write(buffer);
char characters = 0;
while ((character = inSocket.read()) != -1) {
text.setValue((char)character);
//writer.write((char)character);
//characters += (char)character;
}
//text.setValue(characters);
if(str.equalsIgnoreCase("bye"))
{
socket.close();
}
}
catch(Exception e)
{
e.printStackTrace();
text.setValue("You must first start the server application (YourServer.java) at the command prompt.");
}
return form;
}
자바 코드는 "서버가이있어 : 안녕하세요!"
JSF 코드를 실행할 때이 응답을받지 못합니다. 제 실수를 바로 잡으십시오
미리 감사드립니다.
어떻게 jrf_jsf 코드를 만드시겠습니까? – Bozho
대신 무엇을 얻고 있습니까? –
@tomas이 같은 일부 알 수없는 문자 ঠ – mvg