• 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

user authentication and dao

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ....
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Attached where??
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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..
 
bidmi robson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator







 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
bidmi robson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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" ?
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic