jdeisenberg (2) [Avatar] Offline
#1
You can read response.contentType, but it doesn't appear that you can set it directly by assignment. This script:

[pre]response.contentType = 'text/plain';
println "${response.contentType}";
println "Hello, Groovlet.";[/pre]

produces this error using Tomcat 5.5 on Ubuntu 7.04 (line breaks added for readability)

[pre]HTTP Status 500 - GroovyServlet Error: script: '/Hello.grv': Script processing failed.
No such property: contentType for class: org.apache.catalina.connector.ResponseFacadegroovy.lang.
MetaClassImpl.setProperty(MetaClassImpl.java:1396)[/pre]

Changing the first line as follows works:

[pre]response.setContentType( 'text/plain' );[/pre]
Mittie (397) [Avatar] Offline
#2
Re: Page 317: response.contentType
Hi,

this seems to be a special Tomcat 5.5 on Ubuntu 7.04 issue. Please raise the issue at mailt:user@groovy.codehaus.org since it is more of a general Groovy issue than something directly connected to the text of the book.

thanks for posting
Dierk