• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Validate userid and password

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Sheriff
Posts: 67693
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
Jenifer Rajkumar,
Your post was moved to a 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67693
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
A thousand times yes. No Java in a JSP. Ever.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic