Jump to: navigation, search

Difference between revisions of "Jetty/Howto/Develop"

< Jetty‎ | Howto
(Ant Jetty Plugin)
 
(18 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Jetty Howto
 
{{Jetty Howto
| introduction = Jetty Development can roughly be consider from two aspects:
+
| introduction =  
# <b>Developing standard web applications</b> that use only standard APIs, but that are deployed in jetty either for development and/or production.  These web applications may use some jetty APIs, but only as normal WEB-INF/lib libraries.
+
 
# Developing against the <b>jetty APIs</b> for either embedded or closely integrated purposes. This style of development needs jetty jars on the class path during development and runtime
+
{{Jetty TODO}}
 +
 
 +
It is useful to think about Jetty development from two aspects:
 +
* <b>Developing against Jetty APIs</b> for either embedded or closely integrated purposes. This style of development requires Jetty Jars on the class path during development and runtime.
 +
 
 +
* <b>Developing standard web applications</b> that use only standard APIs, but that are deployed in Jetty either for development and/or production.  These web applications might use some Jetty APIs, but only as normal WEB-INF/lib libraries.
 
}}  
 
}}  
 +
 +
 +
== Developing against Jetty APIs ==
 +
Developing against the Jetty API lets you develop both standard web applications and embedded web applications. The basic approach is to install the required [[Jetty/Reference/Dependencies|Jetty Jars and dependencies]] on your class path and then write and run a variation of one of the examples in the [[Jetty/Tutorial/Embedding_Jetty#Web_Application_Context|Embedding Jetty Tutorial]].
 +
 +
For more details about setting up your class path, see:
 +
*  [[Jetty/Tutorial/Jetty_HelloWorld|Jetty HelloWorld Tutorial]]
 +
*  [[Jetty/Tutorial/Jetty_and_Maven_HelloWorld|Jetty and Maven HelloWorld Tutorial]]
  
 
== Standard Web Application Development  ==
 
== Standard Web Application Development  ==
  
To develop a standard web application with jetty, typically you need only the servlet.jar on the classpath of your IDE and then some way to run a jetty server just to test the web application as part of a normal development lifecycle:
+
To develop a standard web application with Jetty, typically you need only the <code>servlet.jar</code> on the classpath of your IDE and then some way to run a Jetty server just to test the web application as part of a normal development lifecycle:
  
 
=== Jetty Maven Plugin ===
 
=== Jetty Maven Plugin ===
  
[http://maven.apache.org/ Apache Maven] is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. It is an ideal tool to build a web application project and such projects can use the [[Jetty/Feature/Jetty Maven Plugin]] to run the web application in development mode.
+
[http://maven.apache.org/ Apache Maven] is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. It is an ideal tool to build a web application project, and such projects can use the [[Jetty/Feature/Jetty Maven Plugin|Jetty Maven Plugin]] to run the web application in development mode.
  
Typically a build tool needs to assemble a web application into a war file, which merges the compiled code, the static content and the deployment descriptor into a zipped file, which can then be deployed in a server.  However, during development, the time taken to assemble a war file can be significant and the resulting bundle can be hard to develop against as source code changes are not immediately reflected.   
+
Typically a build tool needs to assemble a web application into a WAR file, which merges the compiled code, the static content and the deployment descriptor into a zipped file, which you can then deploy in a server.  However, during development, the time it takes to assemble a WAR file can be significant, and the resulting bundle can be hard to develop against as source code changes are not immediately reflected.   
  
Once the [[Jetty/Feature/Jetty Maven Plugin]] is configured for a project, a jetty server can be started with the command:<pre>
+
Once you configure the [[Jetty/Feature/Jetty Maven Plugin|Jetty Maven Plugin]] for a project, you can start a Jetty server with the command:<pre>
mvn jetty:run
+
mvn jetty:run</pre>.
</pre>
+
 
This runs the application directly from its unassembled source components, so that if static content is saved from your IDE's editor, it is immediately visible to the jetty server. If you save a java class, then your IDE will probably compile it on the fly and the plugin will notice the change and redeploy the web application within seconds.
+
This runs the application directly from its unassembled source components, so that if static content is saved from your IDE's editor, it is immediately visible to the Jetty server. If you save a Java class, your IDE will probably compile it on the fly and the plugin will notice the change and redeploy the web application within seconds.
  
 
=== Ant Jetty Plugin ===
 
=== Ant Jetty Plugin ===
The Jetty Ant plugin provides an ant target that allows a jetty server to be run from an ant build.xml file.  
+
The Jetty Ant plugin provides an ant target that allows a jetty server to be run from an ant <code>build.xml</code> file.  
  
This modules is available from jetty@codehaus for Jetty-7, but currently the documentation only exists for [http://docs.codehaus.org/display/JETTY/Ant+Jetty+Plugin jetty ant with jetty-6].  This documentation mostly holds, except the jar names need to be updated for [[Jetty/Reference/Dependencies|jetty-7 jars and dependencies]].
+
This module is available from jetty@codehaus for Jetty-7, but currently the documentation only exists for [http://docs.codehaus.org/display/JETTY/Ant+Jetty+Plugin jetty ant with jetty-6].  This documentation mostly holds, except the Jar names need to be updated for [[Jetty/Reference/Dependencies|jetty-7 Jars and Dependencies]].
  
 
TBD
 
TBD
  
 
=== OSGi Plugin ===
 
=== OSGi Plugin ===
 +
TBD
  
 
=== Eclipse Web Tooling ===
 
=== Eclipse Web Tooling ===
  
=== Embedded Main ===
+
See the Jetty WTP Plugin documentation:
  
 +
[[Jetty_WTP_Plugin|Using the Jetty WTP Plugin]]<br/>
 +
[[Jetty_WTP_Plugin/Jetty_WTP_Install|Installing the Jetty WTP Plugin]]<br/>
 +
[[Jetty_WTP_Plugin/Jetty_WTP_External_WebApp|Using the WTP Plugin with an External WebApp]]<br/>
 +
[[Jetty_WTP_Plugin/Jetty_WTP_Modify_ContextPath|Modifying the Context Path with the WTP Plugin]]
  
 +
=== Embedded Jetty Main ===
  
== Developing against Jetty APIs ==
+
You can write a short Java main to launch your web applications in Jetty directly from your IDE, just as you would run any other Java application.  This allows your IDE's debugger to step through both your application and the server code, and thus allows integrated debugging.
 +
 
 +
See the [[Jetty/Tutorial/Embedding_Jetty#Web_Application_Context|Embedding Jetty Tutorial]] for examples of running a webapp from a main.

Latest revision as of 14:11, 23 April 2013



Introduction

Warning2.png
Some or all of this content remains to be ported to Jetty 9 Documentation.
If you are interested in migrating this content see our contribution guide or contact us.


It is useful to think about Jetty development from two aspects:

  • Developing against Jetty APIs for either embedded or closely integrated purposes. This style of development requires Jetty Jars on the class path during development and runtime.
  • Developing standard web applications that use only standard APIs, but that are deployed in Jetty either for development and/or production. These web applications might use some Jetty APIs, but only as normal WEB-INF/lib libraries.


Developing against Jetty APIs

Developing against the Jetty API lets you develop both standard web applications and embedded web applications. The basic approach is to install the required Jetty Jars and dependencies on your class path and then write and run a variation of one of the examples in the Embedding Jetty Tutorial.

For more details about setting up your class path, see:

Standard Web Application Development

To develop a standard web application with Jetty, typically you need only the servlet.jar on the classpath of your IDE and then some way to run a Jetty server just to test the web application as part of a normal development lifecycle:

Jetty Maven Plugin

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. It is an ideal tool to build a web application project, and such projects can use the Jetty Maven Plugin to run the web application in development mode.

Typically a build tool needs to assemble a web application into a WAR file, which merges the compiled code, the static content and the deployment descriptor into a zipped file, which you can then deploy in a server. However, during development, the time it takes to assemble a WAR file can be significant, and the resulting bundle can be hard to develop against as source code changes are not immediately reflected.

Once you configure the Jetty Maven Plugin for a project, you can start a Jetty server with the command:
mvn jetty:run
.

This runs the application directly from its unassembled source components, so that if static content is saved from your IDE's editor, it is immediately visible to the Jetty server. If you save a Java class, your IDE will probably compile it on the fly and the plugin will notice the change and redeploy the web application within seconds.

Ant Jetty Plugin

The Jetty Ant plugin provides an ant target that allows a jetty server to be run from an ant build.xml file.

This module is available from jetty@codehaus for Jetty-7, but currently the documentation only exists for jetty ant with jetty-6. This documentation mostly holds, except the Jar names need to be updated for jetty-7 Jars and Dependencies.

TBD

OSGi Plugin

TBD

Eclipse Web Tooling

See the Jetty WTP Plugin documentation:

Using the Jetty WTP Plugin
Installing the Jetty WTP Plugin
Using the WTP Plugin with an External WebApp
Modifying the Context Path with the WTP Plugin

Embedded Jetty Main

You can write a short Java main to launch your web applications in Jetty directly from your IDE, just as you would run any other Java application. This allows your IDE's debugger to step through both your application and the server code, and thus allows integrated debugging.

See the Embedding Jetty Tutorial for examples of running a webapp from a main.