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

  • Home
  • SEARCH
  • 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 6151535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:46:52+00:00 2026-05-23T19:46:52+00:00

EDITED: Java httpPost into .asp form I am making an application that will display

  • 0

EDITED: Java httpPost into .asp form

I am making an application that will display some information from the website, which is .asp, to access some of the data I must login. How can I post my credentials(login, password) to the server and get the page in return. I also think that there a lot of redirects on the way, when I login. I have no idea about asp. What I am doing, I am just posting the username, password to the server and I can retrieve the source code of that page with my posted information in the right place. But what do I do next?
I thought That there could be one code snippet that can be used with any .asp website engine.

EDIT: Ok, page code is received
Authentication form has been of IIS type.

when specifuing nameValuePairs use html input (name, value) pairs.

Login form:

<form method="post" id="form1" name="form1" action="">
<input id="txtUser" name="txtUser" type="text" size="13" value="" />
<input id="txtPassword" name="txtPassword" type="password" size="13" value="" />
<input id="BLogin" name="BLogin" type="submit" value="Log in"  />
<input type="checkbox" id="chkSave" name="chkSave"/> 
</form>

some JAVA:

HttpPost httppost = new HttpPost("WEBSITE WITH LOGIN PAGE (Ex: www.qwerty.asd/login.asp)");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("txtUser", "YOUR LOGIN NAME"));
nameValuePairs.add(new BasicNameValuePair("txtPassword", "YOUR PASSWORD"));
nameValuePairs.add(new BasicNameValuePair("BLogin", "Log in"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
response = httpclient.execute(httppost);
entity = response.getEntity();
System.out.println("Login form get: " + response.getStatusLine());
if (entity != null) {
entity.consumeContent();
}
System.out.println("Post logon cookies:");
cookies = httpclient.getCookieStore().getCookies();
if (cookies.isEmpty()) {
System.out.println("None");
} else {
for (int i = 0; i < cookies.size(); i++) {
System.out.println("- " + cookies.get(i));
// httpclient.getCookieStore().addCookie(cookies.get(i));
}
}

Getting headers:

Header[] headers = response.getAllHeaders();
                for(int i=0; i<headers.length; i++){
                    //System.out.println(headers[i]);
                    Header h = headers[i];
                    System.out.println(h.getName());
                    System.out.println(h.getValue());
                }

Proceed to any other page within same service:

HttpPost request2 = new HttpPost(
                    "www.qwerty.asd/information.asp");

            response = httpclient.execute(request2);

            String responseBody2 = EntityUtils.toString(response.getEntity());
            //System.out.println(responseBody2);

            if (entity != null) {
                entity.consumeContent();
            }

For Android Webview to display the web page:

        WebView.loadData(responseBody2, "text/html", "utf-8");
  • 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-05-23T19:46:53+00:00Added an answer on May 23, 2026 at 7:46 pm

    .asp has nothing to do with Android directly.

    You are looking to make a standard HTTP REST request using a WebView.

    Also, here is a page that includes many common tasks in Android as well as links to many tutorials, articles and code samples : http://developer.android.com/resources/faq/commontasks.html

    EDIT: Many might say use a standard alert dialog with a login button BUT I do not believe in the alert dialogs because they have issues. To see an example, create a simple dialog that does nothing and change the screen orientation… it might seem fine but if you look at the LogCat you will see it leaks the activity.

    Therefore, I recommend creating a regular Activity and using the android:theme=”@android:style/Theme.Dialog” in the activity tag in your manifest to make the activity look like a dialog.

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

Sidebar

Related Questions

EDITED: Java httpPost into .asp form I am trying to understand .asp a little
I have a Java class representing an event that contains some data, and also
I have a system that entities (from database, represented as Java objects through ORM)
I'm writing a Java application which requires a number of resource files (there will
Technology(Java EE 6 with Glassfish 3.1, Netbeans 7.0) I have an application client that
I have an application in Java/JSF, I need to do some optimization calculations, like
EDITED with solution (below...) I have a Splash screen that is packaged into it's
(Edited a lot) I've got some classes with Abstracts Members. The concrete type of
--edited for clarity (hopefully) I have an XML file that looks something like this:
[Edited: After cross-testing on a fresh machine and some additional research, this appears to

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.