Nathan -
I believe that I have done what you suggested. I created a class
MyVelocityViewServlet that extends VelocityViewServlet. It contains only
an overridden setContentType(request, response) which pulls an attribute
out of the request and sets the content type of the response based on
the value of the attribute.
Through debugging statements, I can see that the attribute I set is
picked up and the content type is set (to 'text/xml'): nevertheless, the
output of the Velocity template is not being formatted by the stylesheet
at the browser; and, when I look at the page info (in Firefox) the
content type is 'text/html'.
Is there a further step I have to take?
Garey
PS - Here is my setContentType
protected void setContentType(HttpServletRequest request,
HttpServletResponse response) {
String ct = (String)request.getAttribute("contenttype");
if(ct != null) {
System.out.println("contenttype found: " + ct);
response.setContentType(ct);
} else {
System.out.println("no contenttype attribute found");
super.setContentType(request, response);
}
}
Nathan Bubna wrote:
actually, b) is true too. the VVS does explicitly set the content type.
either way, you should extend the VVS. the key method to override is
the setContentType(request, response) method.
to be able to tell what content type to set, you will want to push an
indicator (or the content type value itself) into the request
attributes, pull it out in your setContentType() impl and then call
response.setContentType() there.
On 6/8/07, Garey <[EMAIL PROTECTED]> wrote:
Nathan -
I tried setting the content type from the template and no joy. I
also tried setting the content type in the response
from my logic before passing the request off to the
VelocityViewServlet.
Also no go. I suppose that is because either a) the handoff to the
ViewServlet is a forward so the View servlet doesn't even see my
partial
response, or b) the ViewServlet explicitly sets the content type. Since
a) is more probable, I will probably have to extend the ViewServlet.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]