Mega Code Archive

 
Categories / Java Tutorial / JSP
 

This scriptlet checks a hidden field to see whether or not to throw an exception

<%-- 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>