I have one class named handler and this class process the http request comming from the browser and i want to display the http headers of the request in JTextArea of another class named HttpHeadersFrame! This is what i have tried
public class Handler
{
HttpHeadersFrame headersFrame; //This frame contains JTextArea component
private Request request = null;
public String requestMessage;
private Socket socket = null;
public Handler(Socket socket)
{
this.socket = socket;
this.headersFrame = new HttpHeadersFrame();
headersFrame.setVisible(true);
}
public void processRequest()
{
requestMessage = request.toString(System.getProperty("line.separator"));
headersFrame.getRequestTextArea().append(requestMessage);
}
}
When i run the proxy i don’t get any message in JTextArea! Any help would be appreciated
Firstly, there is lack of proper usage of Swing components in your snippet.
You should initialize the
requestTextAreafield in constructor before using it.And also you have to add it to frame with a statement
You should pass
HttpHeadersFrameinstance to your Handler class, make this instance visible, i.e.And appending
requestMessageto this instance’s textArea field will work.