Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple requests made on each single page load

 
David Rocks
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic