• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Multiple requests made on each single page load

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a filter infront of my JSPs and this seems to be getting called multiple times when I hit a JSP.

I have tracked this down to images in my page with standard img HTML elements causing the requests. It seems that each image will cause another hit on the filter.

The problem is that the filter does a bit of DB work and that is going to kill my server if traffic builds up.

I realise that my filter pattern could be changed but really it has to do many different types of real request so I do want it to be /*

Does anyone have any clues as to how this could be stopped.

TIA
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The filter will match whatever you express as its pattern. Using "/*" it will match anything.

Don't do that.

You'll need to figure out an alternate filter mapping scheme.
 
David Rocks
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So a IMG tag will create a new request just to go from one JSP file in the directory and pick up an gif file ?

Even if I do not use a filter is that not a high load for a simple task.

Struts and hibernate will both tell you to use /* in their filters.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Images are separate requests--not much you can do about that.

You *can*, however, decide to not process the request in the filter if it's an image. S2 uses /* as the filter mapping because we serve static content from specific directories--if the request doesn't match the action pattern or the magic prefix the filter stops processing and moves on.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Images, style sheets, JavaScript files, video and so on are all separate requests.

I'd use a better mapping strategy (unless you are using Struts or whatever -- then use their recommendation), or follow David's advice of writing the filter to determine if it needs to pay attention to a request or not (painful in my opinion).
 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic