• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

ask for login

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to built up a simple login page. what i do is just let user to key in the username and password then will compare to the database . after compare if the username and password valid then direct to the specific. wat the code to use for direct the link automatically without clicking after validation....

thanks,
regards
albert
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm assuming you are using a html/jsp page to take the login information. When the user click on the submit button, you could then use the POST method to post to a JSP or Servlet.


After you post the login information to a jsp, you could get the username and password from the request:


In your jsp page you could then validate the information against the database. If the user enter correct password then you redirect to a secured page, otherwise, you can just redirect to a invalid HTML page, or redirect back to the login page.

It would be helpful if you can look up Model View Controller pattern(MVC) for doing this kind of thing to separate View(Login Page) from the business logic(Login Validation).

I didn't give you the complete code, but this is the general flow that you can follow.

Good luck!
[ February 23, 2007: Message edited by: Eric C Lee ]
 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,

best practice is to use JAAS, in your case with login-method FORM. Look up the general way in the Servlet specification and the way to map it to the relational database in your web container manual.

Kai
 
Bartender
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The simplest solution is to configure Basic Authentication.
A window will pop up and ask for username and password when a protected url (page) is requested.

It's not the most advanced and secure solution, but it will do the job in a lot of situations.

A simple guide can be found on ONJava.

See section 5. Configuring Basic Authentication.

Regards, Jan
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what i want is the method to redirect to specific page code after the validation has done

any expert here can tell me please. thank you

regards
albert
 
Sheriff
Posts: 67590
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

Originally posted by albert sie:
what i want is the method to redirect to specific page



Are you asking how to perform a redirect?

Check the API for HttpServletResponse.
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya when i match the username and password with the database, if match i will go to certain page and if no i will go to another page. how to set it to redirect to that page?
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use <jsp:forward> the way you can forward you page.. to next OR another way to forward by using RequestDispatcher Interface..
[ February 25, 2007: Message edited by: Saif uddin ]
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ya when i match the username and password with the database, if match i will go to certain page and if no i will go to another page. how to set it to redirect to that page?



This can be configured with form authentication. Success and error pages

<jsp:forward>



I would not recommend using the "forward" standard action when the JSP is actually supposed to be a view.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic