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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:37:17+00:00 2026-06-07T21:37:17+00:00

I have an existing and working java web application. I want to make this

  • 0

I have an existing and working java web application. I want to make this application native on android and intend to keep using the same servlets.

The last time I was doing an android application that communicated with the server was placing something like this in the servlet:

PrintWriter out = response.getWriter(); 
out.print("pass"); 

and in the android java class I would do this:

String response = null;
    try {
        response = CustomHttpClient.executeHttpPost(
        "http://10.0.2.2/ProjectName/" + "LoginServlet",postParameters);
        String res = response.toString();
                    if(res.equals("pass")
                    {
                        /**do the things i want**/
                    }
               }
               catch(Exception e)
               {
                   e.printStackTrace();
               }

The servlets that are in my web application uses HttpSession and has a dispatch method like this:

HttpSession session = request.getSession();
session.setAttribute("user",user);

and this:

dispatch(request, response, "/login.jsp");

I added the PrintWriter to the existing servlets which my web application uses it failed.
And this error was produced on logcat:

07-12 08:59:46.344: E/jdwp(487): >>> comparing 'jsp' to 'ers'
07-12 08:59:46.454: E/jdwp(487): >>> comparing 'jsp' to 'nfo'
07-12 08:59:46.524: E/jdwp(487): >>> comparing 'jsp' to 'o$1'
07-12 08:59:46.534: E/jdwp(487): >>> comparing 'jsp' to 'nfo'
07-12 08:59:46.534: E/jdwp(487): >>> comparing 'jsp' to 'o$1'
07-12 08:59:46.594: E/jdwp(487): >>> comparing 'jsp' to 'Key'
07-12 08:59:46.934: E/jdwp(487): >>> comparing 'jsp' to 'ver'
07-12 08:59:47.044: E/jdwp(487): >>> comparing 'jsp' to 'ile'
07-12 08:59:47.334: E/jdwp(487): >>> comparing 'jsp' to 'gin'
07-12 08:59:47.334: E/jdwp(487): >>> comparing 'jsp' to 'nfo'
07-12 08:59:47.354: E/jdwp(487): >>> comparing 'jsp' to 'ame'  
07-12 08:59:47.404: E/jdwp(487): >>> comparing 'jsp' to 'ger'
07-12 08:59:47.404: E/jdwp(487): >>> comparing 'jsp' to 'eme'
07-12 08:59:47.504: E/jdwp(487): >>> comparing 'jsp' to 'ams'

and the list of comparisons go on.

Question: Am I missing something or I should just create new servlets? (I really hope its not the second option)

Edit

I’ve found out that the error is produced by the dispatch method which changes the response to a jsp file instead of just a text string, and commenting out the dispatch method allows me to login to server successfully using android.

However, I want to keep the dispatch method AND the PrintWriter such that both android application and web application can use the same single servlet to login. Anyway I can do that?

  • 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-07T21:37:18+00:00Added an answer on June 7, 2026 at 9:37 pm

    After some research, the answer to this question seems to be a no. There isn’t a way to use the same servlet for the web application and the android application. A new servlet has to be created, no matter if the 2 servlets are 95% the same in content.

    There are few ways that I currently know which the login with android can be done:

    1) using the out.print method as mentioned above. Create PrintWriter object and use the object to do out.print, and check it by response.toString().equals(“expectedString”) in the android java class.

    2) cookies, which I thought could have worked but no, the dispatch method still got in the way. I’m still quite vague when it comes to cookies but apparently you can keep user information in the cookies so the user will be authenticated throughout the use of the application.

    Feel free to add to the answer or correct me if I’m wrong in any of the above.

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

Sidebar

Related Questions

I'm working on an existing Java web application (HTML/CSS/JS/JSP/Servlets and Java classes in this
I'm currently rebuilding an existing PHP application using Java. I therefore have an existing
I have just joined a team working on an existing Java web app. I
I have to make some mods to an existing (and working) magento site. So
I have recently begun working on a pre-existing PHP application, and am having a
I'm working with an existing Android app and I need to have a dynamically
I am working on splitting out an existing, working application that I currently have
I've been professionally working with Java application servers for five years, but I have
I'm working on a project where the client wants to have existing pages dynamically
I have been working with an existing website out company has running until I

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.