• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help on writing a small java server

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic