Forums Register Login

Need help on writing a small java server

+Pie Number of slices to send: Send
I'm writing a tiny web server in java. I've managed to get it to return pages and images to the browser if I hard code in the filename in the code. I want to be able to read the filename from the get request from the browser though. Do I just cut the filename out from the get request? Could someone point me in the right direction please.
+Pie Number of slices to send: Send
A web server can return whatever it wants for a given request. However, for static pages, yes, it is a common thing to send a file that's sitting on the file system. Typically you'd have a base directory where all your pages sit, often called public_html, and then part of the URL would specify a path under that directory. What part of the URL? That depends on your server as well. But for a URL like https://coderanch.com/html/forums/jig/faq.html, it's probably the "/forums/jig/faq.html" part.
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 441 times.
Similar Threads
File Upload Problems
socket communication between mobile browser and proxy server
JSP Reload in opening attachment
Problem with client server programming
Streaming bytes to and from a servlet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:37:49.