简体   繁体   中英

Response.End() in Java/JSP

In .net you have the ability to Response.End() in any context you want. Is there similar functionality in Java/JSP?

Thanks,

Sam

In my experience you have to do the following:

out.flush(); // Send out whatever hasn't been sent out yet.
out.close(); // Close the stream. Future calls will fail.
return; // Return from the JSP servelet handler.

NOTE:
This will not work inside a function because you'll just end up returning from the function but not from the JSP servelet handler (which I'm assuming is your intention).

You could try

servletResponse.getOutputStream().close();

Not quite sure if that will have odd side effects though, in case the server needs to send any data after your content...

Javadoc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM