custom tags and content type

L

luca

no answer on c.l.j.help, so I guess it's time to escalate here :)

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();

//i.e. the tag encapsulates the logic to
//decide which MIME type to send
if (somecondition) {
response.setContentType("text/vnd.wap.wml");
} else {
response.setContentType("text/html");
}
:
}

My JSP file looks like:

<%@ taglib uri="/WEB-INF/tld/tags.tld" prefix="pref" %><pref:document>

(i.e. everything 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 did some tests. 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? is there some place where the appserver decides to send out
the MIME type before I get a chance to change that in my tag?

tomace 4.1.18 here

thanks

luca
 
L

luca

OK, I got this now. What I was trying to do actually works. The bug was
in the place where the condition is evaluated.
I post this, so it stays in the archive. Thank you

luca
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top