Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 687
  • Last Modified:

Login system using a servlet

This is probably straight forward but I am a novice programmer and need help.

I am trying to develop a login for a web application, now I have attached my code used so far, essentially i connect to a oracle database with a table with my valid user names and passwords.
I also have a html form which POST's the username and password to the servlet.

How can I get my servlet to do a check to see and compare the data entered into the html form versus the data from the table (authorised username & passwords) and if they do it will lead onto the next html and if not it will go to a different page (error page).

I have posted the html page i using for login also, in case anyone wants to try it.
<html>
  <head>
  <title>Login Form</title>
  </head>
 
  <body>
  <H2>Please Login:</H2> 
  <FORM METHOD="POST" 
   ACTION="http://localhost:8080/StudentReg/servlet/mylogin" 
   name="myform"> 
  
  <BR>Username: <INPUT NAME="myusername">
  <BR>Surname: <INPUT NAME="mypassword">
  <BR><INPUT TYPE="submit" value="Submit Form"> 
  </FORM>
  </body>
</html>

Open in new window

mylogin.txt
0
bhession
Asked:
bhession
  • 5
  • 4
1 Solution
 
CEHJCommented:
Authentication is built into the web container - in Tomcat it's realm-based. Which one are you using?
0
 
bhessionAuthor Commented:
Im using Tomcat and the eclipse IDE(I dont think that will matter but Im quite a novice here.).
0
 
CEHJCommented:
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
bhessionAuthor Commented:
Im trying to avoid that way but I may have to go that way eventually. I modified some code that I found and I think im just missing something small.

Here is my new code and new html, Im missing something obvious.

I entered in a valid username and password from the table in the database but i tells me its invalid!
<html>
 <body>
  <H2>Please Login:</H2> 
  <FORM METHOD="POST" 
   ACTION="http://localhost:8080/StudentReg/servlet/LoginServlet" 
   name="myform"> 
  
  <BR>Username: <INPUT NAME="ID">
  <BR>Password: <INPUT NAME="PASS">
  <BR><INPUT TYPE="submit" value="Submit Form"> 
  </FORM>
  </body>
</html>

Open in new window

0
 
CEHJCommented:
>>Im trying to avoid that way

Why?
0
 
bhessionAuthor Commented:
Im trying to learn more about servlets
0
 
bhessionAuthor Commented:
Actually on reading that solution you posted a little closer, it seems to be the most logical way.
0
 
bhessionAuthor Commented:
Thanks, it was definitely worth looking at
0
 
CEHJCommented:
:-)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now