GeeCON Prague 2014*
The moose likes Servlets and the fly likes Problem Servlet Filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem Servlet Filter" Watch "Problem Servlet Filter" New topic
Author

Problem Servlet Filter

Abhishek Mehta
Greenhorn

Joined: Feb 24, 2005
Posts: 6
hi friends,
I am using a simple filter just to display a image in a .html or jsp.
its running fine with all jsp and html in both cases,either invoked before or after the page.

But i encounter a problem when it invoked before a html page which contain framset. except the image from the filter nothing get displayed. but if i invoked after the page, both page contents and image from the filter get displayed.

please help me out.
thanks
Abhishek
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Why and how are you using a filter to display an image?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Abhishek Mehta
Greenhorn

Joined: Feb 24, 2005
Posts: 6
hi, thanks for the showing interest.

let me explain my senario. There is a application regarding conference, and on each page i have to insert an image depending on a parameter which is passed. Now i can't make any changes on the servlet running on server, so i used a Servlet Filter which get parameter from the request and according to that display image before the page get loaded as i want the image to be displayed at left top of the page.

But of the of the page contain frameset that creates the problem, the image from the filter get displayed but not the page content if i invoked filter before the page. and invoked after, then no problem.

here i am giving the code of Servlet Filter.


One solution is there i guess it works but don't know how to do that.
cant we put some condition in web.xml using regular expression, which will invoke filter for all pages except the page which contain frameset.

Please help me out from this problem
Thanks
Abhishek
Sharad Agarwal
Ranch Hand

Joined: Sep 11, 2002
Posts: 167
Originally posted by Abhishek Mehta:
One solution is there i guess it works but don't know how to do that.
cant we put some condition in web.xml using regular expression, which will invoke filter for all pages except the page which contain frameset.


Abhishek - you can set the regular expression in the filter code itself. It could parse the HTML to see if it has any framesets in it. In fact, it might not even need to be a regex. It could simply be a case insensitive search for '<frameset'. But, I suspect, over time you will see cases where you may need to tweak it. So, you could start with a regex. Check out Jakarta ORO for your regex needs.

Hope this helps.


Alco-Haul: We move spirits.
Demented Deliberations of a Dilettante
 
GeeCON Prague 2014
 
subject: Problem Servlet Filter