here's my big problem today. I am creating a tag-lib and I need the top tag to
take care of setting the content type. My tag goes like:
public int doStartTag() throws JspException {
try {
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
response.setContentType("text/vnd.wap.wml");
:
}
My JSP file looks like:
<%@ taglib uri="/WEB-INF/tld/tags.tld" prefix="pref" %><pref:document>
(i.e. evrything squeezed on the very first line
to make sure that no char escapes and the default text/html content type
is not generated).
Alas. It doesn't work. I keep getting text/html.
I made some tests and if I set the mime type explicitly in the JSP like below
(after removing the contenttype() line from the taglib) it works!
<%
response.setContentType("text/vnd.wap.wml");
%><%@ taglib uri="/WEB-INF/tld/tags.tld" prefix="pref" %><pref:document>
any idea?
thanks
luca
Tor Iver Wilhelmsen - 05 Mar 2004 21:17 GMT
> any idea?
You can set the content type in a @page directive, if that helps.
luca - 06 Mar 2004 01:39 GMT
>>any idea?
>
> You can set the content type in a @page directive, if that helps.
unfortunately, it doesn't. The mime-type I send is conditional.
It could be text/html or text/vnd.wap.wml
the tag has the logic to decide which....
luca
William Brogden - 06 Mar 2004 13:59 GMT
> here's my big problem today. I am creating a tag-lib and I need the top tag to
> take care of setting the content type. My tag goes like:
[quoted text clipped - 28 lines]
>
> any idea?
Most people would handle this situation by having a front end servlet
decide what response type is needed and forwarding to the correct
JSP. I suspect that the behavior you want to use - of not setting the
response type until the first char is sent - is not a standard and may
change between servlet engines.
Bill