Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 23:11 Go to next message
Kartech Partners is currently offline Kartech PartnersFriend
Messages: 2
Registered: July 2015
Junior Member
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 05:37 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3504
Registered: July 2009
Senior Member

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


Nitin Dahyabhai
Eclipse Web Tools Platform

[Updated on: Sat, 04 July 2015 05:37]

Report message to a 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 21:30 Go to previous messageGo to next message
Kartech Partners is currently offline Kartech PartnersFriend
Messages: 2
Registered: July 2015
Junior Member
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] Thu, 16 July 2015 01:17 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3504
Registered: July 2009
Senior Member

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.

Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Location of the exe in Eclipse Luna (C++)
Next Topic:eclipse RCP Migration 3x to 4x
Goto Forum:
  


Current Time: Mon Sep 23 20:19:42 GMT 2019

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

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

Back to the top