I was trying out a simple example of isErrorPage and errorPage ...follwing is the code
When i execute TestJSP1.jsp for the first time ,it seems as if the exception is not thrown and Hello World is printed...then when i refresh the same page, exception is thrown and 'Sorry there was an error.Please try again!!!' is printed...Why didn't TestJSP1.jsp throw an exception when executed for the first time itself?
This looks to me an issue related to your browser. Perhaps because of the way the browser caches the pages. If you are using Internet Explorer, I will suggest you try following settings: Tools-> Internet Options - > Temporary Internet Files-Settings ->
Here, for 'Check for newer versions of pages' choose 'Every visit to the page'. The default option is 'Automatically'.
Now it should work the way it is supposed to be.
Note: Browser settings may change depending on the browser & the version.
Joined: Jun 17, 2010
Mark Wa wrote:Not sure. try putting your code in the <head> ? - also you dont need to put it in a loop. or an if statement. just throw the exception.
I think she purposefully put the code in if statement. If she didn't so & had tried to throw exception straightaway, the code would not compile because the 'Hello World' statement would become unreachable.