• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Configuration of filter problem

 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Try changing the url-pattern like below :

 
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
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.)
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

if



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




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

 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic