[jetty-users] setting up Eclipse project for embedded Jetty

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jetty-users] setting up Eclipse project for embedded Jetty

Chris Lauwers

Apologies for the novice question, but I’m embedding Jetty into my server, and would like recommendations for what type of Eclipse project setup is best suited for this purpose. The server will primarily provide REST-based web services but also needs to serve up some static (HTML/Javascript) content. I know that if I create a Dynamic Web Content project, Eclipse expects that static content in a WebContent folder and will automatically move this content when creating a WAR file, but since I’m embedding Jetty, a Dynamic Web Content project doesn’t seem like the right way to go.

 

How do I use my Eclipse project setup to manage the HTML content and how do I make sure it ends up in the right place so the embedded Jetty server will find it?

 

Thanks,

 

Chris

 


_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] setting up Eclipse project for embedded Jetty

bubbleguuum
On 01/02/2013 06:44, Chris Lauwers wrote:

Apologies for the novice question, but I’m embedding Jetty into my server, and would like recommendations for what type of Eclipse project setup is best suited for this purpose. The server will primarily provide REST-based web services but also needs to serve up some static (HTML/Javascript) content. I know that if I create a Dynamic Web Content project, Eclipse expects that static content in a WebContent folder and will automatically move this content when creating a WAR file, but since I’m embedding Jetty, a Dynamic Web Content project doesn’t seem like the right way to go.

 

How do I use my Eclipse project setup to manage the HTML content and how do I make sure it ends up in the right place so the embedded Jetty server will find it?

 

Thanks,

 

Chris

 



You do not need anything special for embedded Jetty. A regular java project will do.
For serving static content just use a DefaultServlet, specifying html content root directory (which can be anywhere) with setResourceBase().

_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] setting up Eclipse project for embedded Jetty

Chris Lauwers

Thanks, good to hear I was on the right track.

 

The second part of my question has to do with how to manage this in Eclipse during development. I have my java source files in

 

                ~/Workspace/MyProject/src

 

I’d like to keep the static content in

 

                ~/Workspace/MyProject/html

 

During development, I want Jetty to look in the html directory in my project directory, but when deploying the server, I’d like to move the static content into the directory where the server is deployed. Is there a “standard” way to do this without having to change setResourceBase() right before creating the release build?

 

Thanks,

 

Chris

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of bubbleguuum
Sent: Friday, February 01, 2013 12:16 AM
To: JETTY user mailing list
Subject: Re: [jetty-users] setting up Eclipse project for embedded Jetty

 

On 01/02/2013 06:44, Chris Lauwers wrote:

Apologies for the novice question, but I’m embedding Jetty into my server, and would like recommendations for what type of Eclipse project setup is best suited for this purpose. The server will primarily provide REST-based web services but also needs to serve up some static (HTML/Javascript) content. I know that if I create a Dynamic Web Content project, Eclipse expects that static content in a WebContent folder and will automatically move this content when creating a WAR file, but since I’m embedding Jetty, a Dynamic Web Content project doesn’t seem like the right way to go.

 

How do I use my Eclipse project setup to manage the HTML content and how do I make sure it ends up in the right place so the embedded Jetty server will find it?

 

Thanks,

 

Chris

 

 


You do not need anything special for embedded Jetty. A regular java project will do.
For serving static content just use a DefaultServlet, specifying html content root directory (which can be anywhere) with setResourceBase().


_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] setting up Eclipse project for embedded Jetty

Chris Haynes
Re: [jetty-users] setting up Eclipse project for embedded Jetty There may be a better or an 'official' way of doing this, but, if it helps, this is what I do:

1) I have the normal web.xml file in my WEB-INF directory, containing the invocation of
 the DefaultServlet initialized with the location of my development-environment static files,

2) I have a second file, which I name production-web.xml which has the same content
 except for directing the DefaultServlet to the production location of these resources.

3) I have a makewar.xml Ant file in which the target building the war archive looks like this:

<war basedir="war" destfile="mail.war" webxml="war/WEB-INF/production-web.xml">
       <exclude name="WEB-INF/**" />
       <webinf dir="war/WEB-INF/">
               <include name="classes/**" />
               <include name="**/*.jar" />
       </webinf>
</war>
...


In Eclipse I have added makewar.xml as one of the Builder tasks.

------------

Actually, I have an additional difference between my web.xml and production-web.xml files,
which some may find useful.

I'm using GWT in Eclipse, which has embedded in it a Jetty which uses
"org.mortbay.jetty..." classes, whereas I'm using "org.eclipse.jetty..." classes
in my production environment, so I cite the two different DefaultServlet class paths
in the two web.xml versions.

HTH

Chris Haynes        


On Friday, February 1, 2013 at 7:49:34 PM, Chris Lauwers wrote:
> Thanks, good to hear I was on the right track.

> The second part of my question has to do with how to manage this in
> Eclipse during development. I have my java source files in

>                 ~/Workspace/MyProject/src

> I'd like to keep the static content in

>                 ~/Workspace/MyProject/html

> During development, I want Jetty to look in the html directory in
> my project directory, but when deploying the server, I'd like to
> move the static content into the directory where the server is
> deployed. Is there a "standard" way to do this without having to
> change setResourceBase() right before creating the release build?

> Thanks,

> Chris
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users