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 8393179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:42:56+00:00 2026-06-09T19:42:56+00:00

I am working on an Android web server.When i go to localhost:8080 on the

  • 0

I am working on an Android web server.When i go to localhost:8080 on the emulator browser, it serves a page/form with a password field. On successful verification of the password, I would like to redirect the user to the success/failure page.What would be the best way to read the incoming http post request and parse the password field for verification?Any pointers in the right direction would be greatly appreciated. I have a handler for the url to which the form is submitted. The code for the handler is:

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.entity.ContentProducer;
import org.apache.http.entity.EntityTemplate;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpRequestHandler;

import android.content.Context;

public class LoginHandler implements HttpRequestHandler {
private Context context = null;
public LoginHandler(Context context) {
    this.context = context;
}

@Override
public void handle(final HttpRequest request, HttpResponse response,
        HttpContext httpcontext) throws HttpException, IOException {
       HttpEntity entity = new EntityTemplate(new ContentProducer() {
        public void writeTo(final OutputStream outstream) throws IOException {
            String resp = null;
            OutputStreamWriter writer = new OutputStreamWriter(outstream, "UTF-8");
            if(validatePassword()==true){
             resp ="<html><head></head><body><h1>Home<h1><p>Success.</p></body></html>";
            }
            else{resp="<html><head></head><body><h1>Home<h1><p>Login Failed.</p></body></html>";}
            writer.write(resp);
            writer.flush();
        }


    });
    response.setHeader("Content-Type", "text/html");
    response.setEntity(entity);

}
boolean validatePassword(){
boolean pass=false;
//parse request body here and check for the password if true return true/else false
 return pass;
 }


 }
  • 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-09T19:42:57+00:00Added an answer on June 9, 2026 at 7:42 pm

    After looking around for ages I found the solution. Adding the following in the handle method does the trick.Thanks to the original poster
    .http://www.androiddevblog.net/android/a-bare-minimum-web-server-for-android-platform

            if (request instanceof HttpEntityEnclosingRequest) {
    HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
    if (entity != null) {
    Log.v("RequestBody", EntityUtils.toString(entity, "UTF-8"));
    entity.consumeContent();
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android application and web-server working together. Now I want user log
An android app I'm working on relies on a web page for most of
I'm working on an android app which would connect to a web server which
I'm working on a web server for Android and even though I've spent days
I am trying sending data from android application (with emulator) to web server (a
I'm working on Android project where I'm collecting some information from web server. Everytime
Hi i am working on web service application in android.i need a class that
I am working on a web application for android phones, which is basically few
I have been working on a Android Web Services program that uses a number
I am working on a commercial web application that has a separate mobile browser

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.