aspose file tools*
The moose likes Servlets and the fly likes Configuration of filter problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Configuration of filter problem" Watch "Configuration of filter problem" New topic
Author

Configuration of filter problem

Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Hi All,

I am trying to configure the authentication filter for the entire project, but its not working.


When I replace the project name with one of the folders in the project, it works.

Thanks

Mohamed Inayath
Ranch Hand

Joined: Nov 22, 2004
Posts: 124
Hi,

Try changing the url-pattern like below :

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Mohamed Inayath wrote:Try changing the url-pattern like below :

NO!!!

That will cause the filter to be executed for all requests, including images, JavaScript files, CSS style sheets and so on. Never map "/*"!

What is "FORMS" in this case? (all uppercase? not usually done.)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 687


Hi,

if



This one execute for all your patterns then you can use extension behind it like...




or another *.jsp or aother............


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thanks for the reply.

FORMS is the project name. I want the filter to be excuted for all pages. Maybe using *.jsp will help.

Also when the user first hits a url if he/she is not authenticated (checked in the filter) I would like to redirect to the login page.
How can make the login page submit to the filter?

Thanks

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Justin Howard wrote:FORMS is the project name.

"project name" has no meaning in this context. What is its function in the URL? Is it a folder name? The context path? And why is it capitalized?

I want the filter to be excuted for all pages. Maybe using *.jsp will help.
Really? What about the login page?

How can make the login page submit to the filter?
Not sure what you are asking. You don't submit to a filter, you submit to a resource like a servlet or JSP.

basically, your filter should perform the authentication check (but not for pages that don't need to be authenticated, like the login page) and continue on if all is well, but redirect to the login page if not. The login page should submit to its action that checks the credentials and sets up the session, then traverses to the "main page" of the app (where the filter will check the session for valid authentication).
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
I have this in my login page.


and this in the filter mapping



Why wont this work?

I have the authntication code in the filter.



I am trying to do some.jsp --> filter->(not authenticated)---> login.jsp-->filter-->(authenticated)-->some.jsp
karan wadhwani
Greenhorn

Joined: Feb 22, 2005
Posts: 12
It there any common url pattern when you call jsp ?
or in filter you can check getRequestURI and if it is css or js etc..ignore it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Manish Wadhwani wrote:or in filter you can check getRequestURI and if it is css or js etc..ignore it.

It's a poor practice to incur the overhead of this for each and every request. Rather, configure your patterns wisely and filter only those requests that require it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Configuration of filter problem