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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:28:36+00:00 2026-05-28T04:28:36+00:00

What I try to do Hello Guys, I try to create a login for

  • 0

What I try to do


Hello Guys,

I try to create a login for my server, that I can access the data on it over my app. For this i created a Methode called 'public void doLogin(final String username, final String password)' . In this Methode I start a Thread in which I post the username and password to my server. Now to problem starts. When I do the post my server can’t handle my post which looks like this: '"username="+username+"&password="+password'.

To try if its a serverside problem (infact its not) I made a post over 'curl -d' with the same parameters and I get a response without any problems.

For your information the server runs on Ruby3

Question


How do I need to change my Post to the server that it can handle the data I send. By the way the string I post must look exactly like that: '"username="+username+"&password="+password //this means username=LEUSER&password=LEPASS'

Please tell me what I need to change, some code snippets or tutorials would be great. Down here you find the importrent codesnippets of the doLogin Methode

Code


public void doLogin(final String username, final String password) {

        Thread t = new Thread() {
            public void run() {

                String URL = "http://192.168.110.126:3000/sessions.json"; //für momentane testzwecke

                DefaultHttpClient client = new DefaultHttpClient();
                HttpResponse response;

                try {
                    HttpPost post = new HttpPost(URL);
                    StringEntity se = new StringEntity("username="+username+"&password="+password);
                    post.setEntity(se);

                    response = client.execute(post);

                    if (response != null) {

                    //response handling
                        handler.sendEmptyMessage(0);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                    Log.e("DataHandler", "URLConnection-Error" + e);
                }

            }

        };
        t.start();
    }

Please Guide me Regarding This.

  • 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-28T04:28:37+00:00Added an answer on May 28, 2026 at 4:28 am

    Your code looks like you are sending a html form. In fact curl adds a content-type (with value application/x-www-form-urlencoded) to the http header if you use the -d option.

    So try to add the header field like this:

    HttpPost post = new HttpPost(URL);
    post.addHeader("Content-Type","application/x-www-form-urlencoded");
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I try to do Hello Guys, I'm trying to create a Login-Screen which
First off - hello, this is my first Stack Overflow question so I'll try
When I try this code: dict_a = dict_b = dict_c = {} dict_c['hello'] =
I have a C++ DLL with code like this: LogMessage( Hello world ); try
Hello guys am having a problem with downloading modules. Anytime i try to download
Hello I try to create a function to generate select functions. But the following
I have created a simple vc++ console application and try to print Hello World.
Hello I have this DatastoreNeedIndexException when I try to order by my query. here
What I'm trying to do Hello Guys, I'm trying to create a SplashScreen which
Hello guys i`m trying to delete a row in a access database but when

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.