How to commit HttpServletResponse?

Hi,Is there an elegant way of committing a HttpServletResponse?I want to disable writing any additional data to the response.Thisresponse.getWriter().close()works, but is there a 'proper' way to achieve this functionality?Thanks! :)Peter
[295 byte] By [Peter_Machnera] at [2007-11-27 2:28:47]
# 1
your way is a proper way. There are two ways that I know of to commit the response:1) flush data to the browser (which your close() also does)2) redirect
gimbal2a at 2007-7-12 2:41:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks for your reply :)

I was thinking of some other way, because if I use response.getWriter.close() I get a lot of "Stream closed" exceptions in my trace later on in the application.

I'm using this code as a scriptlet inside a JSP page which is included inside my main JSP page and would like to stop all further JSP rendering.

Any ideas?

Peter_Machnera at 2007-7-12 2:41:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

The proper way to prevent your code from writing anything more to the response is to use an if-statement:if (canWriteMore) {

// write more output

}

Closing the response and then allowing code to try to write to it is only going to result in exceptions.

DrClapa at 2007-7-12 2:41:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Hmm... The problem is that I have a title jsp page which is included in many other jsps. In that title page I check whether there was an error or not and based on that I generate an error message (or not). So I cannot really use such an if statement in the title page because from there I have no access to the data written in the other pages. I guess I'll just have to create such an if statement in all these pages... :/

Peter_Machnera at 2007-7-12 2:41:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...