2 Minutes To Code (β Version)

Java Servlets - 2 minute tutorial

how to set http status code for http response sent to http client

To set the response http status codes, you can use the methods setStatus(int), sendError(int) or sendError(int, String) of the HttpServletResponse object as shown below.

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
	//resp.sendError(603, "Unauthorized access");