how to return http response without creating html output
Meir Yan
Ranch Hand
Joined: Apr 27, 2006
Posts: 597
posted
0
hello all im using tomcat as servlet container and http listener , i have client application that notify with http post requests to the server (tomcat ) when i capture the request im trying to return the client response but all i success to return is the PrintWriter out = response.getWriter(); out.println(" ").....and got print the content of the response to the html my question is how can i response directly to the client ?
If you initiate the request with a browser, the response will be returned to the browser. If you want something else you're going to have to give a lot more information than you have on what you are actually trying to do.
What prevents you from returning a 0-size response? HTTP is a request/response protocol; you can't have one without the other, or you'll confuse the client and/or the server.
Meir Yan
Ranch Hand
Joined: Apr 27, 2006
Posts: 597
posted
0
here is the info my client is c client that construct the http request and send it via winsock send to the ip ort ( that is the tomcat listener ) im not using the browser to send the request . in the server i have simple servlet ( mybe this is my problem ...) that capture the http request via doPost and return me response. thats all .
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35252
7
posted
0
I'll ask again: What prevents you from returning a 0-size response and ignoring it in the client? If for some reason you absolutely, positively can't have a response, then HTTP is not the right communication channel.
Meir Yan
Ranch Hand
Joined: Apr 27, 2006
Posts: 597
posted
0
what do you mean by 0-size response ? i do need to build response string. i can ignore if i have no way other then that .
but an alternative to PrintWriter out = response.getWriter(); out.println(" ").. for text/html
is
ServletOutputStream out = response.getOutputStream(); out.write(Byte); for other mime types. You need to set the response.setContentType ("") though, and your c client needs to be able to handle the content type that is set.
when in doubt put it in parenthesis and stick a dollar sign in front of it, only good can come from this.