wood burning stoves*
The moose likes Servlets and the fly likes HTML username password sending to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTML username password sending to servlet" Watch "HTML username password sending to servlet" New topic
Author

HTML username password sending to servlet

nash avin
Ranch Hand

Joined: Nov 13, 2003
Posts: 96
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

Joined: Nov 01, 2002
Posts: 363
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?


No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Billybob Marshall
Ranch Hand

Joined: Jan 27, 2004
Posts: 202
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

Joined: Mar 19, 2002
Posts: 405
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTML username password sending to servlet
 
Similar Threads
creating a Loginpage.jsp in JSP with LOGIN id and Password.
Calling JNDI from JSP
problem with JSP
JSP page wont call other jsp page!!
html page and servlet interaction Kindly help