开发者

Why is restlet running under tomcat under JBoss 5.1 returning my index.html page as type "application/octet-stream" instead of "text/html"?

I have a home page home.html inside a war file named "webapp-1.0.war". When the browser requests "http://domain/myapp" I want the home.html served up, but I want the browswer address bar to continue to display "http://domain/myapp". I DO NOT want "http://domain/myapp/home.html" in the address bar.

So I put this into the web.xml:

<welcome-file-list>
  <welcome-file>home.html</welcome-file>
</welcome-file-list> 

And I added a 开发者_如何转开发jboss-web.xml with the following:

<jboss-web>
  <context-root>myapp</context-root>
</jboss-web>

This almost works. When the browser requests "http://domain/myapp" the home.html is sent, but the mime type is application/octet-stream instead of text/html, and this makes Firefox think it is a file download.


"octet-stream" is the default mime-type in Restlet. The "html" is defined in the default mapping. Looks like you have your own MetaDataService. You can add extension mappings like this,

getMetadataService().addExtension("html", MediaType.TEXT_HTML, true);


This is not the default behaviour.

Mime types are normally definied in web.xml. In case of Tomcat and clones, the appserver-default mime types are definied in /conf/web.xml.

This can however be overridden by custom mime mapping entries in the webapp's /WEB-INF/web.xml or by a HttpServletResponse#setContentType() in a servlet or filter in the request-response chain. I can imagine that there is some sort of poor filter listening on /* which incorrectly sniffs and sets the content type based on the request URL. See if something similar exist in your webapp.


It does indeed appear to be the default behavior of Restlet. After thinking about it some more, I suppose I like the behavior. Thinking RESTfully, I suppose the web app as a whole (which is what is implied by the root url) is not really the resource my browser is interested in retrieving. The browser is really interested in an html representation of the "home" resource, which is a part of the web app. So I guess I'll leave it. But I'll go ahead upvote you, BalusC for taking the time to answer for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜