File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Populating a list before performing login Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Populating a list before performing login" Watch "Populating a list before performing login" New topic

Populating a list before performing login

anand tiwari

Joined: May 05, 2007
Posts: 1
Hi all,

I need to implement a particular logic in my web application (its a struts application) where I want to populate an arraylist before the user performs the login operation. This is needed as I want to compare certain user attributes after the user had logged in.

Can this be done using a separate servlet having the load-on-startup value specified? Will the particular servlet be available only when i restart the servlet or it will be available if I redeploy the application?

Can someone please suggest an appropriate solution for the same as I am new to both servlets and struts.

amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 544
You can use a Servlet Filter to do this.
You need to
1) Implement the business logic that you mentioned in the Servlet Filter class
2) Configure this filter to be invoked whenever your login servlet gets called

Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

If this is a one time operation I would suggest taking a look at a servletcontextlistener instead.

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Ankush Kaundal
Ranch Hand

Joined: May 12, 2011
Posts: 36

Go for Filters, it is the best thing you can do without modifying your existing servlets code.
I agree. Here's the link:
subject: Populating a list before performing login
It's not a secret anymore!