• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTML username password sending to servlet

 
nash avin
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I wanted to know given a html page that contains "username" and "password" options.I want to send the values that are being typed in the username and password options to a servlet.
Kindly let me know how this is done in detail.I have written a little piece of code to do this.The code is below

In the form tag I am finding it difficult as to how it can be done.
Kindly let me know.
Hoping to hear from you.
Thanking you
AS
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This seems fine to me. Now in the AuthenticateServlet2 servlet's doGet method, you can retrieve the values by:
String username = request.getParameter("username");
String pw = request.getParameter("password");
What problem are you having, specifically?
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of things to consider, since you're dealing with "sensitive" information (user names and passwords):
1) Use "POST" instead of "GET" - otherwise the values get sent as clear text on the URL, regardless of whether you're using SSL or not.
2) Use SSL so that the values aren't sent as clear text in the POST headers.
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also since the the "POST" method is better way to go because the data will not be seen as a part of the URL. You need to put your code in the doPost method instead of the doGet method. Also it is very common to forward doPost and doGet paramaters to a single method, something similar to below:


or you can do this:

I hope this helps
craig
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic