Announcement Announcement Module
Collapse
No announcement yet.
Response header Content-Type ;charset= woes for binary type Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Response header Content-Type ;charset= woes for binary type

    I have a custom view, that renders a binary response and therefore charset encoding scheme is irrelevant (and incorrect) to be specified after the content type:

    Content-Type: anybinary/type;charset=ISO-8859-1

    By default "ISO-8859-1" is set. Originally my code was based on a standard Servlet and when going back to the servlet I get the correctly emitted headers. So the culprit as far as I can see is the spring framework trying to be too clever for its own good.

    Another header I do not want to see is the "Content-Language: en-GB" again this header is not relevant to the content being served, as this piece of content is language neutral. How can this header be removed completely ?



    So how is it possible to get a raw Servlet behaviour, ideally I think there should be a org.springframework.web.servlet.view.ServletView class to setup this exact behaviour to allow someone port across a standard Servlet generated response into the spring framework.

    An alternative approach would be for me to go back to using a Servlet for this response however I have not understand how its possible to get access to Spring's beans to be able to make DAO access in the Controller phase.

    Maybe its possible to create the servlet as /WEB-INF/jsp/foobar.do so that no outside party can access it directly, make it lookup request.getAttribute() for model data. Then run a Spring controller like normal and forward the view to /WEB-INF/jsp/foobar.do to get the required response.

  • #2
    Originally posted by dlmiles
    Maybe its possible to create the servlet as /WEB-INF/jsp/foobar.do so that no outside party can access it directly, make it lookup request.getAttribute() for model data. Then run a Spring controller like normal and forward the view to /WEB-INF/jsp/foobar.do to get the required response.
    I've try this as best I can and can't get it to work.

    javax.servlet.ServletException: Could not resolve view with name '/WEB-INF/jsp/foobar.do' in servlet with name 'myTest'

    I'm using a view bundle and as stated I can't see any obvious way to directly reference a Servlet as a view renderer, maybe a org.springframework.web.servlet.view.ServletView should be written to fill that gap. So I could do:

    foobarView.class=org.springframework.web.servlet.v iew.ServletView
    foobarView.url=/WEB-INF/jsp/foobar.do


    I also dont think I was clear enough before with the Content-Language header. I am using <bean id="messageSource" class="org.springframework.context.support.Resourc eBundleMessageSource"> so suspect this is coming from that bean. However while I do wish to have multi-language support for language specific content, there are some parts of the application that are language neutral and it would be good control which is which, and which I want as the default. As it stands now the default is to presume content is language specific, where as I'd prefer to presume language neutral and mark out resources that are language specific.

    Comment


    • #3
      Ah ha! After a day of head scratching and experimentation, it has been possible to undo the setLocale() and setContentType() by executing:

      response.reset();

      On the HttpServletResponse within the view, now the HTTP headers are as clean as I get with a pure servlet .

      Comment

      Working...
      X