Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Validate userid and password

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2265
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your jsp file should be under WebContent folder and java source files(e.g. servlet) should go under Java Resources.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Marshal
Posts: 67445
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jenifer Rajkumar,
Your post was moved to a https://coderanch.com:80/t/564535";" target="_new" rel="nofollow">new topic. Please be sure to start new topics for new questions.
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Bear Bibeault
Marshal
Posts: 67445
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A thousand times yes. No Java in a JSP. Ever.
 
They weren't very bright, but they were very, very big. Ad contrast:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic