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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:29:57+00:00 2026-06-06T18:29:57+00:00

For testing purposes I want to use Jetty 8 to serve only static content.

  • 0

For testing purposes I want to use Jetty 8 to serve only static content. I know how to start the webserver from the command line:

java -jar start.jar jetty.port=8082

I would like to be able to use a vanilla Jetty, preferably 8 or 7, and start it using something like:

java -jar start.jar OPTIONS=resources resources.root=../foo jetty.port=8082

The files should then be accessible from the root of the server. A file called ../foo/x.html should be accessible via http://localhost:8082/x.html.

I don’t want to create a WAR file or anything fancy. Preferably it shouldn’t do any caching on the server side, leaving the files unlocked on Windows machines. Also, I only want to serve files, even located in subdirectories, no fancy file browser or ways to modify them from a client.

Is this possible? If not, what is the minimum configuration needed to accomplish such behavior?

Additional information

I’ve tried the following command. I expected to be able to browse the javadoc shipped with Jetty 8 using http://localhost:8080/javadoc/, but it always gives me a 404

java -jar start.jar –ini OPTIONS=Server,resources etc/jetty.xml contexts/javadoc.xml

  • 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-06T18:29:58+00:00Added an answer on June 6, 2026 at 6:29 pm

    The simplest way to start Jetty and have it serve static content is by using the following xml file:

    static-content.xml:

    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
    
    <Configure id="FileServer" class="org.eclipse.jetty.server.Server">
        <Call name="addConnector">
          <Arg>
              <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <Set name="host"><Property name="jetty.host" /></Set>
                <Set name="port"><Property name="jetty.port" default="8080"/></Set>
              </New>
          </Arg>
        </Call>
    
        <Set name="handler">
          <New class="org.eclipse.jetty.server.handler.ResourceHandler">
            <Set name="resourceBase"><Property name="files.base" default="./"/></Set>
          </New>
        </Set>
    </Configure>
    

    Than you can start Jetty using:

    java -jar start.jar --ini static-content.xml files.base=./foo jetty.port=8082
    

    If you omit files.base, the current direcory will be used; if you omit jetty.port, port 8080 will be used.

    The --ini will disable the settings from start.ini, therefore also make sure no other handlers etc. will be activated.

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

Sidebar

Related Questions

When I use this code to download this image (only used for testing purposes),
Possible Duplicate: Deflate command line tool Yes, I know I can use PHP itself
For testing purposes, I want to use a DialogBox for logging into my application.
I use IIS 7.5 on windows 7 to serve my asp.net websites for testing
for performance testing purposes I want to take a small XML file and create
For testing purposes, I want to replace the implementation of a few methods of
For testing purposes, I placed two databases on the same server, I want to
For testing purposes, I'm looking for a simple way to start a standalone JNDI
For testing purposes only, I am allowing my app APK to be downloaded and
How can I prevent Django, for testing purposes, from automatically fetching related tables not

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.