0

As a kind of personal project, I'm trying to develop a Java Applet that will stream from a collection of music that I will host on the same machine as the applet. I know when you request files in an applet, it looks for them in the files of the computer which is accessing the applet. I, however, want to access files that are hosted on the same server as the applet.

My intention is to, when the client wants to stream a specific song, the server will begin loading the data and streaming the data to the client. I think this would be possible using the URL class in Java, but would that not be going out to the internet only to come back to the very same server to get its files? Or will it recognize that the files are local and access them without going out to the web?

Summary: What is the best way for an applet to access files that are hosted on the same server as itself?

1 Answer 1

1

An applet runs on the client machine. In order to access files the server you're going to have implement functionality on the server-side to expose those files to your client. There are various ways to do this in Java - the most common would be:
1) a custom servlet or
2) a web service

Here are some links to articles which could be helpful:

As an aside I think your question is quite broad. You're probably going to have to investigate one or both of the methods above, try to implement one of them and then come back to SO with more specific questions.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the quick response. I'll check these out this afternoon.
I think after reading up on the links you listed I would want to implement one of those two (probably a servlet.) However, for the time being, I just want the applet to be able to access files that are accessible via URL. It has occurred to me that my thinking in terms of applets was wrong and that a URL would be the way to go here. However, when it comes time to access my entire music library, which is not hosted to the web obviously, I will consult the information you posted. Thanks for your help!
"expose those files to your client ... the most common would be: .." ..Putting the resource in the same directory as the page that loads the applet.
That's true but that also allows direct access to the files which is not what I'll want eventually. Besides I don't want to move the entirety of my music library into my web server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.