OutputStream and servlet

B

bigbinc

Does anybody know how servlet for example tomcat writes data to the
socket outputstream. For example,

based on the code below and getWriter, should I call 'flush' within my
code for example if I have a lot of data being outputted or will
out.flush() doing anything because servlet engines process output till
the end. Lets say I have a string that is 1MB, should I parse the
string up and do a out.flush() or just
do:
out.print(BIG_STRING)
out.flush();

jasper,tomcat performs out.write... for each line of text.

It looks like the buffer size is 8k.

_jspx_out = out;

out.write("// aimsBuffer.js\r\n/*\r\n* JavaScript template file
for ArcIMS HTML Viewer\r\n*\t\tdependent on aimsXML.js,
ArcIMSparam.js, aimsCommon.js, aimsMap.js, aimsIdentify.js,
\r\n*\t\t\taimsSelect.js, aimsQuery.js, and aimsLayers.js\r\n*\t\tTo
be interactive, dependent also on aimsDHTML.js, aimsClick.js, and
aimsNavigation.js\r\n*/\r\n\r\naimsBufferPresent=true;\r\n\r\nvar
drawTargetLayer = true;\r\nvar bufferTargetLayer = \"\";\r\nvar
bufferTargetLayerIndex = 0;\r\nvar bufferDistance = 5;\r\nvar
bufferSmoothEdges = 1/100;\r\n\r\nvar getBufferedData =
false;\r\n\r\n/*\r\n***************************************************************************************\r\n\r\nBuffer
functions \r\n\r\n***************************************************************************************\r\n*/\r\n\r\nfunction
writeBufferForm() {\r\n\tvar url = appDir + \"buffer.htm\";\r\n\tif
(useTextFrame) {\r\n\t\tparent.TextFrame.document.location =
url;\r\n\t} else {\r\n\t\tWin1 =
open(url,\"BufferWindow\",\"width=575,height=150,scrollbars=yes,resizable=yes\");\r\n\t}\r\n\r\n}\r\n\r\n\r\n//

++ Code ++

public void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {

loadVariables();

// get parameters
String _mainCommand = request.getParameter("cmd");

String _minx = request.getParameter("minx");
String _maxx = request.getParameter("maxx");
String _miny = request.getParameter("miny");
String _maxy = request.getParameter("maxy");


String _the_id = request.getParameter("featureid");

// continue with the output

String _output_type = "text/html";

if (_mainCommand != null) {

if (_mainCommand.equals("xml")) {

// run xml ping
_output_type = "text/xml";

response.setContentType(_output_type);
PrintWriter out = response.getWriter();

cleanErrorXML(out);

out.flush();
out.close();

return;

} else {

_output_type = "text/html";

} // end of the if - else

} else {

_output_type = "text/html";

} // end of the if - else


response.setContentType(_output_type);
PrintWriter out = response.getWriter()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top