Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java Servlets
Expertise: Beginner
Feb 18, 2000

GET and POST Requests

Question:
How does a servlet handle GET and POST requests?

Answer:
The HttpServlet abstract class, defined in the javax.servlet.http package, contains several methods that simplify interacting with HTTP requests. Two of the methods take care of handling GET and POST requests. When you write a servlet, you should subclass HttpServlet and implement the doGet() method to handle GET requests. Similarly, to handle POST requests, you would implement the doPost() method.

Both methods take an HttpServletRequest instance and an HttpServletResponse instance as arguments. The HttpServletRequest instance contains all the information pertaining to the request, including any request parameters. The HttpServletResponse is used to generate a response to the request.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap