• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTML username password sending to servlet

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic