DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Easiest Way To Do A POST Test From Java
I need to test services with POST transactions. Using HTML to do it is the easiest way, constructed in Java (that part isn't necessary unless the args are somehow cooked or just too complex to trust hand-crafted HTML).
// write the HTML code out to stdout -- leave it to the user to redirect System.out.print( "<html><body><form id='test' name='test' action='" ); System.out.print( url ); System.out.print( "/getStuff' method='POST'><input type='hidden' id='cid' name='cid' value=\"" ); System.out.print( compId ); System.out.print( "\"/><input type='hidden' id='ids' name='ids' value=\"" ); System.out.print( ids ); System.out.print( "\"/>" ); System.out.print( "<input type='submit' name='Submit' value='Submit'></form></body></html>" ); System.out.println();