Vai al contenuto

Web Science/Part1: Foundations of the web/Dynamic Web Content/Handling a post request in a Java Servlet/quiz

Da Wikiversità, l'apprendimento libero.

1 How can HTTP header fields of an HTTP request be accessed in the Java code snippet which uses Jetty as an embedded servlet?

Retrieve the data from the socket using a reader class.
Retrieve the data from the socket using an input stream class.
There are methods on the request object for accessing HTTP header fields
Inside of the doGet and doPost methods exist objects which have access to the header fields.

2 What should one do when accessing request parameters or HTTP headers and processing them inside a server?

The user input retrieved from the fields should be escaped before running database queries
The video demonstrated everything that should happen. Nothing more needs to be done.