Changes

Jump to navigation Jump to search
108 bytes removed ,  18:39, 1 December 2023
m
Text replacement - "syntaxhighlight" to "pre"
If the URI http://localhost:8080/hello/World is accessed, the result will be:
<syntaxhighlight pre lang="xml">
<response>
<title>Hello World!</title>
If you post something (e.g. using curl or the embedded form at http://localhost:8080/)...
<syntaxhighlight pre lang="shell">
curl -i -X POST --data "message='CONTENT'" http://localhost:8080/form
</pre>
...you will receive something similar to the following result:
<syntaxhighlight pre lang="shell">
HTTP/1.1 200 OK
Content-Type: application/xml; charset=UTF-8
</pre>
<syntaxhighlight pre lang="xml">
<response type="form">
<message>'CONTENT'</message>
The values are the result of HTML forms submitted with the (default) content type <code>application/x-www-form-urlencoded</code>:
<syntaxhighlight pre lang="xml">
<form action="/process" method="POST" enctype="application/x-www-form-urlencoded">
<input type="text" name="city"/>
Files can be uploaded to the server by using the content type {{Code|multipart/form-data}} (the HTML5 {{Code|multiple}} attribute enables the upload of multiple files):
<syntaxhighlight pre lang="xml">
<form action="/upload" method="POST" enctype="multipart/form-data">
<input type="file" name="files" multiple="multiple"/>
The server can invite the client (e.g., the web browser) to make a second request to another URL by sending a 302 response:
<syntaxhighlight pre lang="xml">
<rest:response>
<http:response status="302">
A server-side redirect is called forwarding. It reduces traffic among client and server, and the forwarding will not change the URL seen from the client’s perspective:
<syntaxhighlight pre lang="xml">
<rest:forward>new-location</rest:forward>
</pre>
Errors that occur outside RESTXQ can be caught by adding {{Code|error-page}} elements with an error code and a target location to the {{Code|web.xml}} configuration file (find more details in the [http://www.eclipse.org/jetty/documentation/current/custom-error-pages.html Jetty Documentation]):
<syntaxhighlight pre lang="xml">
<error-page>
<error-code>404</error-code>
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu