This scriptlet checks a hidden field to see whether or not to throw an exception : Scriptlet « JSP « Java Tutorial






<%-- This scriptlet checks a hidden field to see whether or not to throw an exception --%>
<%
  String hiddenField = request.getParameter("hiddenValue");
  if ( hiddenField == null || hiddenField.equals(""))
    throw new java.lang.NullPointerException();
%>

<HTML>
  <HEAD><TITLE>Generate Error</TITLE></HEAD>
  <BODY>
    This page generates an error when you click the button.<P>
    <FORM METHOD="POST" ACTION="generateErrorNoHandler.jsp">
      <INPUT TYPE="HIDDEN" NAME="hiddenValue" VALUE="Bang!">
      <INPUT TYPE="SUBMIT" VALUE="Generate exception!">
    </FORM>
  </BODY>
</HTML>








23.29.Scriptlet
23.29.1.Scriptlet Example
23.29.2.Call function in jsp page
23.29.3.Count to 10 Example using JSP Scriptlet
23.29.4.All Scripting Elements
23.29.5.This scriptlet checks a hidden field to see whether or not to throw an exception