Java (current. Jakarta) Server Pages is a framework used for web application development.

This post will discuss:

  • Application Object
  • HTTP Response Codes and Error Pages


Application Object


The Application object in JSP is an implicit server-side (servlet) object that can be called from any client instance. It has get, set, remove methods.

Methods for application object:

setAttribute(“attr”,”value”):
Sets attribute.
getAttribute(“attr”):
Gets attirubte value.
removeAttribute(“attr”):
Removes specified attribute.
getAttributeNames():
Gets attribute names as enum.


To illustrate it’s scope,



Exception/Error Pages


All web servers will return HTTP responses for requests, and may sometimes return error codes. The web server will respond with an HTTP error code, wrapped in it’s own page depending on the server software. If the response page presents the page code, this may be an undesirable behavior, as it exposes code to the client.

Error Codes:

404:
Page not found. Resource does not exist.
500:
Internal server errors.
200:
Request succeeded.
307:
Temporary redirect.
400:
Client error, bad request.
405:
Method not supported for the resource.
503:
Server down.

To redirect to any specific page beyond the server software’s default, define this in the directive tag.

<%@ page errorPage="error_page.jsp">

For the page that is landed on:

<%@ page isErrorPage="true">


-gonkgonk


<
Previous Post
Java Server Pages - Session Object
>
Next Post
Java Database Connectivity - Basics 1