Thanks Craig for clarification...

I've another question on that line..

I'm actually using the i18n tag library in the same jsp page. That is, it
looks something like this:

<%@ page import="com.cisco.appadmin.login.ui.LoginController" %>
<jsp:useBean id="controller" scope="request"
class="com.cisco.appadmin.login.ui.LoginController" ></jsp:useBean>
<%@ taglib uri="http://jakarta.apache.org/taglibs"; prefix="i18n" %>
<i18n:bundle baseName="com.cisco.appadmin.text.resources.LoginRB"
locale="<%= controller.getLocale() %>" />
<% response.setContentType("text/html;charset=" + controller.getCharset());
%>

So, it should be OK in jsp1.2 spec ( i.e. Tomcat 4.x version), right!!

The reason am asking is, looks like the tag "<i18n:bundle" also sets the
content type but I want the content-type to be set based on my databean.
Based on your reason, this should work because am overwriting the content
type with "<% response.setContentType("text/html;charset=" +
controller.getCharset()); %>"...
And, container will wait until, the buffer is filled (or flushed)..

Please correct me if am wrong!!

Thanks for your time,
-Ratnakar



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Craig
R. McClanahan
Sent: Friday, September 07, 2001 12:18 PM
To: [EMAIL PROTECTED]
Subject: RE: Servlet/JSP - content-type


On Fri, 7 Sep 2001, Ratnakar  Palle wrote:

> Date: Fri, 7 Sep 2001 12:07:07 -0700
> From: Ratnakar  Palle <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: RE: Servlet/JSP - content-type
>
> Hi Craig,
>
> Thanks for your quick response...
> I understand that RequestDispatcher.forward() erases any headers but I'm
not
> setting any header info in the servlet. I want to set it in the jsp, how
do
> I do that!!
> I've the charset info in the databean and I want to use that bean to set
it
> in the jsp like I indicated in my previous mail:
>
> <%@ page language="java" %>
> <jsp:useBean id="controller" scope="request"
> class="apps.test.LoginController" ></jsp:useBean>
> <% response.setContentType("text/html;charset=" +
controller.getCharset());>
> %>
>
> Any idea??
>
> Hope I was clear!!
>

Ah, missed that little detail ... I jumped to an incorrect conclusion when
you said "model 2" :-)

In a JSP 1.1 environment (i.e. Tomcat 3.x), the character set used on the
output page itself is determined by when the container calls
response.getWriter().  There is no spec language to define this, so
containers are free to do what they want -- and Tomcat calls
response.getWriter() before your scriptlet has the chance to do anything.
Therefore, your custom character encoding is ignored.

In a JSP 1.2 environment (i.e. Tomcat 4.0), the container is supposed to
wait before calling getWriter() until you fill the buffer (or flush it
yourself).  Therefore, your code should work in Tomcat 4.

> Thanks,
> -Ratnakar
>

Craig

>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Craig
> R. McClanahan
> Sent: Friday, September 07, 2001 9:45 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Servlet/JSP - content-type
>
>
> Calling RequestDispatcher.forward() erases any headers that have been set
> by the servlet, so your technique is not going to work.  You will have to
> set the content type in the JSP page.
>
> Craig
>
>
> On Fri, 7 Sep 2001, Ratnakar  Palle wrote:
>
> > Date: Fri, 7 Sep 2001 09:35:36 -0700
> > From: Ratnakar  Palle <[EMAIL PROTECTED]>
> > Reply-To: [EMAIL PROTECTED]
> > To: [EMAIL PROTECTED]
> > Subject: Servlet/JSP - content-type
> >
> > Hi All,
> >
> > I'm using model 2 architecture, i.e. request comes to servlet, servlet
> does
> > the process and creates the bean and forwards it to JSP. Finally, jsp
> sends
> > the response to the client.
> > But, I've a question about the content-type. My bean, should set the
> > content-type on jsp and I don't want jsp to set the default
content-type.
> >
> > I'm doing something like this:
> > <%@ page language="java" %>
> > <jsp:useBean id="controller" scope="request"
> > class="apps.test.LoginController" ></jsp:useBean>
> > <% response.setContentType("text/html;charset=" +
> controller.getCharset());
> > %>
> >
> > But, looks like jsp is ignoring the content-type set by me because jsp
by
> > itself sets the default content-type as I didn't provide any contentType
> > parameter with "<%@ page " tag.
> >
> > Do you've any idea, how to overcome this situation??
> >
> > Thanks,
> > -Ratnakar
> >
> >
>
>

Reply via email to