• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need suggestion regarding an issue related to content type header

 
Ranch Hand
Posts: 63
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have web application and I prepare war file for deployment. Classes are put inside {location}/WEB-INF/classes location and static contents like images, javascript files, static jsps, etc. are put at following location {location}/resources/.
When I tried to access static resources from browser (url : http://{domain name}/resource/{resource name}), no filter of web app is called. Even filter which is set for every request is not getting called. Can anybody provide some suggestion on this?
And one more thing, if I want to set content type in response header for static resource then how can I set that?

I need help on this.Please provide your views on this.

Thanks to all in advance for their suggestions.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What filter mappings have you setup?

As for the content types for static resources, as far as I know these can only be setup in the web.xml file, in a mime-mapping element.

I'll move this thread to our Servlets forum.
 
Abhishek Purwar
Ranch Hand
Posts: 63
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply Rob.

Following are the filter mapping which I set up:

<filter>
<filter-name>{filter name 1}</filter-name>
<filter-class>{Class name}</filter-class>
</filter>
<filter-mapping>
<filter-name>{filter name 1}</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>{filter name 2}</filter-name>
<filter-class>{Class name}</filter-class>
</filter>
<filter-mapping>
<filter-name>{filter name 2}</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

For static resource, none of this get called.

And I set the mime-mapping in web.xml but nothing happens. (.png file get parsed by browser and shows character stream in browser instead of image, .ico file same as .png and for some other types of file also.) Following is mime-mapping which I setup in web.xml file :

<mime-mapping>
<extension>png</extension>
<mime-type>image/x-png</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ico</extension>
<mime-type>image/x-icon</mime-type>
</mime-mapping>

And I am using weblogic server for my application and environment is linux.

Please provide some suggestion for this.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Abhishek,

Try * inplace of /* in <url-pattern>/*</url-pattern> tag to map all requests if you have only one application deployed.

-Sujata
 
Abhishek Purwar
Ranch Hand
Posts: 63
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Filter mapping issue is fixed and now filter is getting called for every request.

Any suggestion for content type issue??
 
Sujata Samal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried setting the contectType in response object something like - response.setContentType("image/png") ??

-Sujata
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no response for static images, only in servlets and JSP pages. That's the whole issue.
 
Abhishek Purwar
Ranch Hand
Posts: 63
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your responses.

@Sujata : I need to set content type for all static resources at common place and not in some class file.

@Rob: Actually, mime-mapping I setup at wrong place in web.xml file. Now I place it just befoe welcome-file-list tag and it is working now.

Issue is resolved.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Evil is afoot. But this tiny ad is just an ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic