Wednesday, January 1, 2014

The incredibly useful TCP Monitor in STS/Eclipse

I was recently working on a project that posted JSON objects from a java client to PHP server. I really needed to see what the HTTP headers and data looked like. I know that you can use the browser debuggers to view the requests and responses, but these are formatted. I find it really helpful to see the data just as it appears.

To view the monitor in STS (and presumably Eclipse), select "window", "show view", "other", "debug", and choose "TCP/IP Monitor".

You'll see a display tab that says "TCP/IP Monitor".  Next click on the tiny, upside-down triangle off to the right, select "show header", and then and select "properties".  This brings up a display box where you add the normal server port on the left (e.g. localhost:8080), and the "proxy" local port on the right (e.g. localhost:9111). Start it by clicking the "start" button, and the TCP/IP monitor will now forward any requests to port 9111 on to port 8080 and show you the http request and response.

For example, if I enter this url:

http://localhost:9111/spring-mvc-ajax-master/

instead of the one I normally would use, "http://localhost:8080/spring-mvc-ajax-master/", I get the display below, which shows me the headers and data for both the request and response.






No comments:

Post a Comment