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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:41:04+00:00 2026-05-20T20:41:04+00:00

I am developing an Android App that gets some data from a web server,

  • 0

I am developing an Android App that gets some data from a web server, which I (or rather someone else) also create myself. Now, just for testing, I wanted to set up a simple Jersey Web Service that I can access via “httpGet”. What I aim to achieve is to send some ?test request and get a “test!” String back. However, I have never worked with Web Servers before, so I feel kind of lost atm.

I followed a German “Hello World” example (it’s supposed to show “Yeah” when calling the site localhost:8080/rest/message from the browser).

That’s how my code looks:

import java.io.IOException;
import java.net.InetAddress;

import javax.swing.JOptionPane;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.ext.Provider;

import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.net.httpserver.HttpServer;

@Path("test")
@Provider
public class Test
{
    private static InetAddress adress;

    public static void main(String[] args)
    {   
        try
        {
            publishSite();
        }
        catch (IllegalArgumentException e)
        {
            e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        System.out.println("Der WebServer wurde unter der Adresse \"http://" + adress.getHostAddress() + ":8080/test\" veröffentlicht.");
    }

    public static void publishSite() throws IllegalArgumentException, IOException
    {
        adress = InetAddress.getLocalHost();
        HttpServer server = HttpServerFactory.create("http://" + adress.getHostAddress() + ":8080/");
        server.start();

        JOptionPane.showMessageDialog( null, "Ende" );
        server.stop( 0 );
    }


}

(Here I got some errors saying “Access restriction: The type HttpServer is not accessible due to restriction on required library C:\Programme\Java\jre6\lib\rt.jar” which I changed into warnings following some other website’s guide. Bad idea?)

and, from the example mentioned above:

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@Path("message")
public class Message {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String message() {
        return "Yeah! ";
    }
}

Now, if I try to access localhost:8080/test/message, I get an empty page. The same with localhost:8080/test. BUT, also the same with any random URL I can think of, like localhost:8080/blblab – which seems a bit weird to me.

Trying to access it from my Android App, I get an 404 error on localhost:8080/test/message and an 405 error on localhost:8080/test.

If it helps, I will post the Android code as well; but I have tested it on Google before and got some html string back so I think it’s not the cause of my problem.

Hope you can help and also that my question isn’t too stupid. 🙂 Thanks in advance!

P.S.: please add “http://” to all the local links above in your mind, I am not allowed to post more than 2 links. ^^

  • 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-20T20:41:05+00:00Added an answer on May 20, 2026 at 8:41 pm

    Ok, it WAS a stupid question! ^^ It worked fine once I looked at localhost:8080/message instead of localhost:8080/test/message…

    However, if anybody knows why I don’t get an 404 response in my browser, I am still happy for another answer!

    Also, with the “Access restriction” error, I found an easy solution here, in tgigiel’s post.

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

Sidebar

Related Questions

In my Android app, I have some data that needs to be synced daily
I am developing an app for android mobiles that communicates with a json/rest web
I am developing an Android app that needs to receive specific informations for each
I am developing an Android app which needs to poll a specific webpage in
When developing whether its Web or Desktop at which point should a developer switch
When developing a new web based application which version of html should you aim
I have been developing an Android app and testing with a 1.5 AVD and
I'm in the middle of developing android app using google map. My question is
I am developing an Android App and would like to have a video file
Hi I am developing an Android App where I require a user to authenticate

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.