aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes user authentication and dao Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "user authentication and dao" Watch "user authentication and dao" New topic
Author

user authentication and dao

bidmi robson
Greenhorn

Joined: Sep 12, 2010
Posts: 16
can anyone please help out.i`m trying to make use of a relay servlet to manage request and responses.i also want to use a dao(data access object) to
connect to the database..the relay and login codes are hereby attached..can you please show me where to place my redirection to another page in the login code.i want to
forward the 2 group of users namely:admin and users to different pages...also how do i write a simple and effective dao
for this web application? thank you ....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Please be sure to take the time to compose descriptive subjects for your posts. You will attract people who will can give you better and faster answers when your posts have good, descriptive subjects. For more information, please click this link ⇒ UseAMeaningfulSubjectLine.

Using a title such as you used isn't going to attract the attention of those who can best help you.

You can change your subject line by clicking the button on your post.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Attached where??


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Chetan Natu
Greenhorn

Joined: Dec 03, 2005
Posts: 19
bidmi robson wrote:can anyone please help out.i`m trying to make use of a relay servlet to manage request and responses.i also want to use a dao(data access object) to
connect to the database..the relay and login codes are hereby attached..can you please show me where to place my redirection to another page in the login code.i want to
forward the 2 group of users namely:admin and users to different pages...also how do i write a simple and effective dao
for this web application? thank you ....


I'll take up the part which I have clearly understood.

What you can do is retrieve the information from the web page, while you are authenticating the user, retrieve the type/role of the user from the User Database (You can do this two ways, simple: pick from the database, difficult: map it with your userdirectory). Based on the role simply write an if..else code and redirect to corresponding servlet/JSP/component.

And of course it would help if you could attach the code as well

Hope that helps..

Never Remember the failure
Never Forget the mistake
bidmi robson
Greenhorn

Joined: Sep 12, 2010
Posts: 16
Chetan Natu wrote:
bidmi robson wrote:can anyone please help out.i`m trying to make use of a relay servlet to manage request and responses.i also want to use a dao(data access object) to
connect to the database..the relay and login codes are hereby attached..can you please show me where to place my redirection to another page in the login code.i want to
forward the 2 group of users namely:admin and users to different pages...also how do i write a simple and effective dao
for this web application? thank you ....


I'll take up the part which I have clearly understood.

What you can do is retrieve the information from the web page, while you are authenticating the user, retrieve the type/role of the user from the User Database (You can do this two ways, simple: pick from the database, difficult: map it with your userdirectory). Based on the role simply write an if..else code and redirect to corresponding servlet/JSP/component.

And of course it would help if you could attach the code as well

Hope that helps..



i dont seem to get it. all athe formats of doc i want to attach are not allowed then what are the allowed formats..i tried notepad,wordand even zip, nothing seems to work..can you help caused i`m just pissed by all that..
Chetan Natu
Greenhorn

Joined: Dec 03, 2005
Posts: 19
If nothing seems to work, then just copy paste the code into the reply window and enclose it with the code tag like this

bidmi robson
Greenhorn

Joined: Sep 12, 2010
Posts: 16







Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 519
    
    2

Hi Bidmi,

From your code, it seems your post is going to Relay which is supposed to relay the task of authentication to another servlet (I don't know why). First of all, why do you need two servlets for this task. You could have called a DAO directly from relay and redirect the response to the respective page using RequestDispatcher or something like that. That seems to be pretty simple.

But just in case, you need to call another servlet, how are you managing the connection? Have you tried looking into Interservlet Communication another URL you should be looking is How communication. There are several things which you need to consider, whether both of your servlets running under same context or different.



Regards
KumarRaja

bidmi robson
Greenhorn

Joined: Sep 12, 2010
Posts: 16
Kumar Raja wrote:Hi Bidmi,

From your code, it seems your post is going to Relay which is supposed to relay the task of authentication to another servlet (I don't know why). First of all, why do you need two servlets for this task. You could have called a DAO directly from relay and redirect the response to the respective page using RequestDispatcher or something like that. That seems to be pretty simple.

But just in case, you need to call another servlet, how are you managing the connection? Have you tried looking into Interservlet Communication another URL you should be looking is How communication. There are several things which you need to consider, whether both of your servlets running under same context or different.



hello, can you please help with aclue on how to write the dao.i.e the structure dao normally follows..i`m hearing about dao for the very first time and dont know how to go about it..is it in the dao also that all the sql statements will be ? how do i set the context thing in netbeans...i`m using netbean 6.9.1 with tomcat server...
thank you..
Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 519
    
    2

Hi Bidmi,

DAO (Data Access Object) is a J2EE design pattern which you can learn more at DAO. This pattern abstracts your data access from the rest of the layers and you can implement several data access with out impacting the rest of the system. In general, this would involve an Interface having your data access methods, with required implementations and you can use a factory to create the required instance of that.

By using DAO, you can get an instance of the data access implementation in your web layer or some other layer as needed and perform the data access operations. Your can move your entire DB access code to this DAO layer thus freeing your web from data access ( A good design would not include any data access in web layer, in real time systems).


Context can be considered as "something" your webapplication will have and access to get more information about the environment it is running. I can't define context in a better way . Every web app will have a context defined by the container it is running and with in a container, all the web apps share the same context. In this case, this is called ServletContext. You do not need to specify this. You can access your context say from your servlet config. There are several questions on ServletContext in this forum, which you can go through for better understanding.

bidmi robson
Greenhorn

Joined: Sep 12, 2010
Posts: 16
is there nobody who can take a look at this code and tell me what is wrong with it...all responses so far have not been helpful..
Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 519
    
    2

bidmi robson wrote:is there nobody who can take a look at this code and tell me what is wrong with it...all responses so far have not been helpful..


Where is your "relay" servlet calling "Login" ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: user authentication and dao