Approved: Fortect
Here are some simple steps that should help you solve your publishing issue to a Java Servlet.
Instructions / Server Tutorials / Publishing requests
- GET requests
- URL and request parameters
- POST requests
- Publication
- Move to publication
- JSP
- Request with AJAX
- Publishing with AJAX
- Other approaches
- Other types of requests
- Homework
- Next: Libraries
By now, we should know that the target (like a web browser) is working by simply sending a request to the server. The server responds to this request with all the content of the file (for example, any type of HTML, image, CSS, or file) and even content dynamically generated from a servlet or JSP. The client then plays it again to please the user.
The requests we use only receive content from the server. This tutorial shows how to use many other types of requests so that clients can send data to the server as well.
GET Requests
So far, we have learned how to write HTML files that a client (web browser) can very easily request from a server. We also learned how to write a servlet or JSP file that creates HTML content, which is then sent to the client.
This type of use request is called a GET
request because the client receives material from most of the server. All thuWhat we’ve done so far is a GET
request.
URL And Request Parameters
We have already seen that you can send data to the server. We have seen information about query parameters such as:
This URL will ask for the names.html
file and happily use the name
parameter for Ada
. We could then use client-side JavaScript or server-side Java to get that exact parameter.
We’ve also seen how to use URLs yourself to send data to some server:
Then we could use a special servlet that / names / *
wants something so that market buyers can ask for any name they want. We could then use server side Java code to parse the url and get the name.
- URLs stored in the user’s history. This might be fine in this example, but probably not very good when entering passwords or credit card information. This will allow someone else to get your login details just by looking at your history!
- URLs mustWe are created on time. For example, how do you ask the user to enter the We logo? could write code that creates a URL based on user input, but that’s an unreliable pain in the neck.
- URLs can be up to 2083 characters long. It can be expensive, but what if you post something like a blog or article that uploads a file?
To get around these limitations, we can use a different request type.
While GET
requests are a client looking for content from a server, post
requests are a client that sends data to a specific server. One of the easiest ways to do this is to use any