Skip to main content



      Home
Home » Newcomers » Newcomers » Starting Jetty server 9.3 from command line to server static content(Jetty9 server to serve static content)
Starting Jetty server 9.3 from command line to server static content [message #1700576] Fri, 03 July 2015 19:11 Go to next message
Eclipse UserFriend
Hi,

Please can someone outline the steps to start jetty web server from command line to that it can server static content . I am using version 9.3.x .

Couple of examples from google to setup jetty 9 for serving static content did not help . The documentation also was not very helpful.

Appreciate your help in this regard.

Thanks
Kartech
Re: Starting Jetty server 9.3 from command line to server static content [message #1700580 is a reply to message #1700576] Sat, 04 July 2015 01:37 Go to previous messageGo to next message
Eclipse UserFriend
Since you're not embedding it within an application of your own, you should get the full jetty-distribution download. Its 'bin' directory will contain a rather complex script for running Jetty.

The simplest steps are to make a folder in the unpacked "webapps" directory to represent your web application's static content root, include an empty WEB-INF directory in there, and then to run Jetty with "java -Djetty.port=8080 -jar start.jar". Here's a sample layout once unpacked:

jetty-distribution-9.3.0.v20150612/
jetty-distribution-9.3.0.v20150612/webapps/
jetty-distribution-9.3.0.v20150612/webapps/myapp/
jetty-distribution-9.3.0.v20150612/webapps/myapp/WEB-INF/
jetty-distribution-9.3.0.v20150612/webapps/myapp/index.html

[Updated on: Sat, 04 July 2015 01:37] by Moderator

Re: Starting Jetty server 9.3 from command line to server static content [message #1701808 is a reply to message #1700580] Wed, 15 July 2015 17:30 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for your mail.

I set up a standalone jetty instance. I created a folder
myapp under webapps folder within jetty. I am trying to test a simple page that uses a js file (angularjs) and a css file(bootstrap).

webapps
----- myapps
-----------WEB-INF
-----------angular.js
-----------bootstrap.css
-----------bootstrap-theme.css
-----------test.html

On entering the URL http://localhost:5051/myapp/test.html in the browser The test.html page does not load the css and js files. Debugging using Chrome I see that it returns a HTTP 404.
Can you help me understand why jetty cannot find and load the static content such as js and css files under myapp?

If I remove the js and css file references in the HEAD in the html file, the html file renders with "Test class" as expected.

Below is the content of my test.html file
<!DOCTYPE html>
<html ng-app>
<head lang="en">
    <meta charset="UTF-8">
    <title>Work Order Tracker</title>
    <script src="angular.js"/>
    <link href="bootstrap.css" rel="stylesheet"/>
    <link href="bootstrap-theme.css" rel="stylesheet">	
</head>

<body>
    <div class="btn btn-default">{{"AngularJS"}}</div>
    <div class="btn btn-success">Bootstrap</div>
    <h1> Test class</h1>
</body>
</html>


Re: Starting Jetty server 9.3 from command line to server static content [message #1701816 is a reply to message #1701808] Wed, 15 July 2015 21:17 Go to previous message
Eclipse UserFriend
Are there any case mismatches or permission issues at play? I've not tried to serve CSS, but static content has generally just worked in my uses, including directory listings.
Previous Topic:Location of the exe in Eclipse Luna (C++)
Next Topic:eclipse RCP Migration 3x to 4x
Goto Forum:
  


Current Time: Tue May 13 07:04:29 EDT 2025

Powered by FUDForum. Page generated in 0.07604 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top