4.1. Understand more details of the HTTP protocol
HTTP protocol is used to transfer resources between a client and a server.
HTTP is stateless.
HTTP is stateless.
The information is identified by URL (uniform resource locator).
URL structure: protocol://machine:port/context/resource
URL structure: protocol://machine:port/context/resource
Methods in HTTP
- HEAD : get metainfo contained in headers
- GET : get a resource from the server
- POST : send data included in the body to the server to be processed (get,add or update)
- PUT : send a resource(file) to the server by a new connection.
- DELETE: delete a resource
- TRACE : to obtain a response code from the server
- OPTIONS : to obtain http methods supported
- CONNECT : to transform connection to https
- PATCH : to modify partially a resource in the server.
Response codes in HTTP
The most common are:
- 4XX - Error in client side
- 5XX - Error in server
4.2. Understand fundamentals of HTML forms
A html form has these attributes:
- action : resource
- method : GET or POST
- GET : add form data to the URL using ? as separator (QueryString)
- POST : the data is sent into the body.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>FORM EXAMPLE</title> | |
<style> | |
p { | |
border:1px solid grey; | |
padding:10px; | |
margin:30px; | |
} | |
</style> | |
</head> | |
<body> | |
<form action="order.jsp" method="GET" enctype="text/plain" name="sendInfo"> | |
<p> | |
ORDER <br> | |
<input type="text" maxlength="20" size="20" name="order"> | |
</p> | |
<p> | |
TAKE AWAY <br> | |
<input type="Radio" name="takeAway" value="N" checked> No<br/> | |
<input type="Radio" name="takeAway" value="Y"> Yes<br/> | |
</p> | |
<p> | |
SIDES/DRINKS <br> | |
<input type="checkbox" name="topic" value="chips" checked>chips<br/> | |
<input type="checkbox" name="topic" value="salad" checked>salad<br/> | |
<input type="checkbox" name="topic" value="coke">coke<br/> | |
<textarea name="other" cols="20" rows="10">Other</textarea> | |
</p> | |
<p> | |
MENU NUMBER <br> | |
<select> | |
<option value="menu1">menu1</option> | |
<option value="menu2">menu2</option> | |
<option value="menu3">menu3</option> | |
</select> | |
</p> | |
<input type="Button" name="bt" value="Send"> | |
</form> | |
</body> | |
</html> |
- Textfield
- Radiobutton
- Checkbox
- Buttons
- SelectionList
- TextArea
When the submit button is clicked the form-data is sent to a page on the server called "order.jsp"
See next post The Servlet's Environment (part2)
OCEJWCD (SCWCD) - 1Z0-899 - Web Component Developer Certification
No comments:
Post a Comment