Skip to content
This repository was archived by the owner on Jan 27, 2021. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>Exceptions Example</title></head>


<body>
<h1>Exceptions Example</h1>

<p>This example demonstrates how to throw and map exceptions using ExceptionMapper in Jersey resource classes.</p>

<h2>Contents</h2>

<p>The example consists of just one Jersey resource:</p>
<dl>
    <dt><code>com.sun.jersey.samples.exceptions.MyResource</code></dt>
    <dd>that produces a textual response to an HTTP GET.</dd>
</dl>
<p>The mapping of the URI path space is presented in the following table:</p>
<table border="1">
    <tr>
        <th>URI path</th>
        <th>Resource class</th>
        <th>HTTP methods</th>
    </tr>

    <tr>
        <td>/myresource</td>
        <td>MyResource</td>
        <td>GET</td>
    </tr>
    <tr>
        <td>/myresource/runtime</td>
        <td>MyResource</td>
        <td>GET</td>
    </tr>
    <tr>
        <td>/myresource/checked/ioexception</td>
        <td>MyResource</td>
        <td>GET</td>
    </tr>
    <tr>
        <td>/myresource/checked/mymappedexception</td>
        <td>MyResource</td>
        <td>GET</td>
    </tr>
    <tr>
        <td>/myresource/checked/mymappedruntimeexception</td>
        <td>MyResource</td>
        <td>GET</td>
    </tr>
    <tr>
        <td>/myresource/checked/mymappedthrowingexception</td>
        <td>MyResource</td>
        <td>GET</td>
    </tr>
    <tr>
        <td>/myresource/webapplicationexception/{status}</td>
        <td>MyResource</td>
        <td>GET</td>
    </tr>

</table>

<h2>Running the Example</h2>

<p>Run the example as follows:</p>

<p> run
<blockquote><code>mvn clean compile exec:java</code>

    <p></blockquote>
<p>From a web browser, visit:</p>
<blockquote><code><a href="http://localhost:9998/myresource">http://localhost:9998/myresource</a></code></blockquote>
</body>
</html>