| Author |
Validate userid and password
|
P Arunkumar
Ranch Hand
Joined: Jan 05, 2012
Posts: 87
|
|
Hi
I need to validate my user id and password that was in jsp, for validation what technique i can use like servlet or struts. iam new to developing side please guide me.
Now iam developing login page by jsp in my-eclipse with tomcat please guide me if i want to use servlet means how and where i want to store the files and if struts what are the jar files i want to download.
Thanks in advance.
Jenifer Rajkumar
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 990
|
|
|
Your jsp file should be under WebContent folder and java source files(e.g. servlet) should go under Java Resources.
|
Swastik
|
 |
Palash Nandi
Ranch Hand
Joined: Jul 09, 2009
Posts: 34
|
|
Hi jenifer,
There is no fixed rule regarding what you need to use. It all depends on how you validate the userid and password. Since you are new to jsp , I would suggest you not to use struts as it will make it unnecessarily complex. You can use simple jsp or Java classes for validation.
Some basic guidelines:
1. Use a basic html page for userid and password and put it in a <form> tag. let the action of the form tag point to a validate.jsp( the name can be anything ) file.
2. inside the validate.jsp , you can retrieve the previous useris/password using "request.getParameter('userName')" and password similarly.
3. Then you can pass this to a java method in your java class where you can write the logic for validating it. You can simpley hardcode the logic or if you haave a database , retrieve the data from there and validate.
4. According to the returned value you can do a simple out.println("success") or failure on the jsp.
Once you get this running, you can go on and make it more complex. Since you are new, i would not advise you to start with struts with packages as they do a lot of things for you. Which may look good in the start, but once you get stuck, it will be a nightmare.
So best of luck!!
|
A TubeBulb May light slowely... But it lights the Brightest..
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
Jenifer Rajkumar,
Your post was moved to a new topic. Please be sure to start new topics for new questions.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Prasad Krishnegowda
Ranch Hand
Joined: Apr 25, 2010
Posts: 461
|
|
Palash Nandi wrote:
2. inside the validate.jsp , you can retrieve the previous useris/password using "request.getParameter('userName')" and password similarly.
I would not advice a beginner to do this. You should not write Java code inside JSP, start with good programming habits.
|
Regards, Prasad
SCJP 5 (93%)
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
|
A thousand times yes. No Java in a JSP. Ever.
|
 |
 |
|
|
subject: Validate userid and password
|
|
|