Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:03:36+00:00 2026-06-01T12:03:36+00:00

I dont think this is possible to do, so perhaps I need a totally

  • 0

I dont think this is possible to do, so perhaps I need a totally new way of looking at the problem.

My java program connects to a web form and logs in. I have the username and password form another part of the code.
The HTML form will contain different input types obviously. Depending on the user, and the site, each field will be named differently. Here’s a sample web form:

<FORM METHOD=POST ACTION="/my.form">
Username:
<INPUT NAME="username">
<BR>
Password
<INPUT TYPE="PASSWORD" NAME="password">

<INPUT TYPE="HIDDEN" NAME="my-hidden-name" VALUE="someValue">

<BR><INPUT TYPE="SUBMIT" VALUE="Login">
</FORM>

In this form, the NAME fields can be anything and will change form site to site. I’ve gotten around this by requiring a PROPERTIES file that stores the fields, eg:

username
password
my-hidden-name=someValue
SUBMIT=Login

This works for half of the above fields. The problem is the username and password fields.

I already have the username and password, so I COULD just do: if(currentField=="password") string=mypass123. but then what if someone makes a form where the username/password field is called user1 or passwordField, or basically anything other than what I’ve put in the if()!!

So, can anyone suggest a way I can handle any combination of names, and still identify which ones are the username and password fields? Here’s my current code:

//Read file logic here
Properties formProps=getDataFromResource(pathToFormFieldsPropfile);

if(null!=formProps)
{
    //Gets a list of all the field names, eg "username", "password", "submit"
    Enumeration<?> formFields=formProps.keys();
    while(formFields.hasMoreElements())
    {
        String tempString=(String) formFields.nextElement(); //This gets the field name
        query+=tempString   //Will contain field name
                +"="        //Used as a divider in the querystring, ie field=value
                +formProps.get(tempString)  //Value corresponding to field
                //+ URLEncoder.encode((String) formProps.get(tempString),Charset.defaultCharset().toString())   //The value needs to be encoded for POST
                +"&"; //The trailing one of these will have to be removed at the end
    }
}

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:03:38+00:00Added an answer on June 1, 2026 at 12:03 pm

    Just to follow up on this, I managed to come up with a way to fix this, but its probably not ideal.

    Basically, I make it so the user must have the username and password as the first and second blank entries in the PROPERTIES file.

    Then in my code I have a counter that says, if ((counter++)==0), insert username and then if ((counter++)==1), insert password, followed by else leave it blank.

    This works for what I need to do, but may not be ideal.

    PS, I implemented a custom Property class to make sure they’re all ordered, as the default method stores them in an unordered list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't think this is possible, but if is then I need it :)
I don't think this is possible, but I'll ask anyway... Is there some way
I don't think this is possible but I thought I'd throw it out there.
I don't think this is currently possible or if it's even a good idea,
I don't think this can be done cleanly, but I'll ask anyway. I have
I don't think this is particularly quirky, but in an attempt to control my
I don't think this is technically a macro but I don't know what else
I don't think this question has been asked before. I'm a bit confused on
I would like to do the following but I don't think this will work:
This is perhaps a result of bad design, but here it goes. I wasn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.