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

common URL Mapping for filter

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

I have an admin module in my web application and all the admin related jsp pages are in folder "webadmin";

eg: www.test.com/webadmin/home.jsp.


I want to write an authentication filter for admin module and i want to route all request that comes to webadmin/*.jsp to the filter.

How to give the the url patter in the filter config.
doesnt work.

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

This is what i am doing in one of my applications to intercept requests. Check this out.

Servlet code


A user token is placed in the session after successful authentication in the servlet. It is removed when the session expires or when the user logs out.
The login page should call the servlet for authetication with an identifiable query. In this example, the link in login.jsp's form would probably look like "http://domain/servlet/auth?cLogin". (see below).

We check for the token first and if it is valid, we don't care about the query string. This setup helps avoid circular calls (especially since we do a forward as opposed to a redirect).
Authentication is valid only when a user token exists in the session. But we let the request proceed if the user is logging in.
If authentication fails and we have a valid configuration, we simply forward the request to the login page again. Otherwise, we throw an exception (we should really never get here ...). The default error page for the application would likely pick that up.

Web.xml

Code snippet for Login Page

Code snippet for Servlet:
- Obviously would be called from a doPost() method that's already extracted the parameters from the request if one of the parameters is "cLogin".



That's it. After you deploy a web application with this filter, all requests will be intercepted and authentication checked.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this : <url-pattern>/webadmin/*</url-pattern>
 
It means our mission is in jeapordy! Quick, read this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic