I am trying to emulate this REST APi using Jersey JAX-RS

(too bad I can't put in the reference URLs so I will make a summary)

Basically, it is a API that performs authentication using Custom HTTP Header and where serviceToken is hardcoded(is it a good idea to hard code serviceToken)

<code>
<!DOCTYPE html>
<html>
<head>
<title>REST Tester</title>
<meta charset="UTF-8">
</head>
<body>
<div id="logMsgDiv"></div>

<script src=</script>
<script type="text/javascript">
var $ = jQuery.noConflict();

$.ajax( {
cache: false,
crossDomain: true,
dataType: "json",
url: "",
type: "GET",
success: function( jsonObj, textStatus, xhr ) {
var htmlContent = $( "#logMsgDiv" ).html( ) + "<p>" + jsonObj.message + "</p>";
$( "#logMsgDiv" ).html( htmlContent );
},
error: function( xhr, textStatus, errorThrown ) {
console.log( "HTTP Status: " + xhr.status );
console.log( "Error textStatus: " + textStatus );
console.log( "Error thrown: " + errorThrown );
}
} );

$.ajax( {
cache: false,
crossDomain: true,
dataType: "json",
url: "",
type: "POST",
success: function( jsonObj, textStatus, xhr ) {
var htmlContent = $( "#logMsgDiv" ).html( ) + "<p>" + jsonObj.message + "</p>";
$( "#logMsgDiv" ).html( htmlContent );
},
error: function( xhr, textStatus, errorThrown ) {
console.log( "HTTP Status: " + xhr.status );
console.log( "Error textStatus: " + textStatus );
console.log( "Error thrown: " + errorThrown );
}
} );

$.ajax( {
cache: false,
crossDomain: true,
dataType: "json",
url: ",
type: "PUT",
success: function( jsonObj, textStatus, xhr ) {
var htmlContent = $( "#logMsgDiv" ).html( ) + "<p>" + jsonObj.message + "</p>";
$( "#logMsgDiv" ).html( htmlContent );
},
error: function( xhr, textStatus, errorThrown ) {
console.log( "HTTP Status: " + xhr.status );
console.log( "Error textStatus: " + textStatus );
console.log( "Error thrown: " + errorThrown );
}
} );

$.ajax( {
cache: false,
crossDomain: true,
dataType: "json",
url: "/",
type: "DELETE",
success: function( jsonObj, textStatus, xhr ) {
var htmlContent = $( "#logMsgDiv" ).html( ) + "<p>" + jsonObj.message + "</p>";
$( "#logMsgDiv" ).html( htmlContent );
},
error: function( xhr, textStatus, errorThrown ) {
console.log( "HTTP Status: " + xhr.status );
console.log( "Error textStatus: " + textStatus );
console.log( "Error thrown: " + errorThrown );
}
} );
</script>
</body>
</html>
</code>

So, the above code is a client used to test out the REST API in which I am not allowed to put the link here.

The author has suggested to make the REST-API into a war before use the client to call out the result.



The author was using username and password and I have used JPA with eclipselink and Hibernate to retrieve the 2 variables running on Tomcat server. The rest of my WebApp are on based on Java EE framework.

I am also hoping to use email address to replace username if the whole things work. Hope that it is ok to do it this way.

My problem is that I do not know how to test the REST-API without creating a .war file so I hope someone can tell me cos it was a long time I did REST and can't recall how to do it.

Thank you.