Skip to main content

Error Pages

ErrorPages configurations( Exception Handling configurations in JSP)
-->The page that executes only when exception is raised in jsp is called errorPage. It is useful to display non technical guiding messages to end user when exception is raised
-->There are 2 types of error pages configurations in jsp
a.)Local Error Page configuration
-->Using errorPage, isErrorPage attributes( <%@page%>)
-->Specific to one jsp page
b.)Global Error Page configuration
-->Using <error-page> tags of web.xml file)
-->Common for all jsp page of web applications

a.)Local Error page configuration

-->The error page (err.jsp) executes only when the exception is raised in main.jsp to display non-technical guiding messages to end user when exception is raised
  1. JspApp4-LocalErrorPage
  2. |-->webContent
  3.       |-->main.jsp
  4.       |-->err.jsp
main.jsp
  1. <%@page errorPage="err.jsp"%>
  2. <b>from main.jsp</b>
  3. <% int a=integer.parseInt("a10");%>
  4. Value is:- <%=a%>
err.jsp
  1. <%@page isErrorPage="true"%>
  2. <p>internal problem </p>
  3. <hr>
  4. <%=exception%>
-->Gives request to main.jsp
-->The implicit object exception is visible only in error jsp page and it can be used to display exception related messages as non technical guiding messages
b.)Global Error page configuration
-->Common for all the jsp pages of web application, must configurations in web.xml file
  1. JspApp5-GlobalErrorPage
  2. |-->webContent
  3.      |-->main.jsp
  4.      |-->err.jsp
  5.      |-->WEB-INF
  6.             |-->web.xml
-->We can take html file as error page but not recommend to take because we can't use the implicit object exception
-->While working with global error pages configurations we can configure different error pages for different exceptions
In web.xml
  1. <web-app>
  2.   <error-page>
  3.      <exception-type>java.lang.NumberFormatException</exception-type>
  4.      <location>/err.jsp</locations>
  5.   </error-page>
  6.   <error-page>
  7.      <exception-type>java.lang.NullPointerException</exception-type>
  8.      <location>/myErr.html</locations>
  9.   </error-page>
  10. </web-app>
Note: Jsp error pages configurations is no way related to servlet error pages
-->If we configure both local and global error pages on certain main jsp file , then the configurations done in local error page executes
(Q) What is the difference between  the implicit object page & pageContext ?
In JES class
  1. final java.lang.Object page=this;
  2. pageContext=_jspxFactory.getPageContext(this,request,response,"err.jsp"(error.jsp),true(session mode),8192(buffer size),true(autoFlush mode));
page
-->Holds JES class object reference
-->Useful to differentiate scriptlet tags variables from declaration tag variable when both have got same name
pageContext
-->Holds details about current jsp page like request, response, error page, buffer size and etc...
-->Useful to create different scopea of attributes like request /session/ application and etc...

Comments

Popular posts from this blog

JSP Comments

Comments in JSP:- -->Compiler /Interpreter doesn't take commented code for compilation /Interpretation, so the commented code doesn't participate in execution JSP supports 3 types of comments:- a.)HTML comments /Template text comments/ Output comments Syn :- <!---text---> -->Recognized by html interpreter of browser b.)JSP comments /Hidden comments Syn :- <%--text--%> -->JSP page compiler recognize these comments c.)Java comments /Scripting comments Syn :- //-->For single line /*-- -----*/-->For multiple line -->Java compiler(java) recognize these comments -->In Eclipse IDE JES class for first.jsp comes in our(workspace)folder/.metadata/.plugins/.org eclipse Comments (1)JSP comment<%--%> (2)Java comment(// or /*--*/) (3)HTML comments(<!---> JES Source Code (1)No (2)Yes (3)Yes In JES compiled code (1)No (2)No (3)Yes In the code going to browser (1)No (2)No (3)Yes Output (1)No (2)No (3)No -->Jsp comments are not visible in any phase...

Project Architecture's

1.) Functional flow/ Architecture a.) Only for 6+/7+years b.) Explain the flow of process/business 2.) Technical Flow/Architecture a.) Upto 5+ years b.) Explain technologies /components that are involved in the project Servlet & JSP Project Architecture:- 1.)What is need of Business Deligate to convert VO class object to DTO class object ? a.) If Business Deligate is not there servlet component directly prepares DTO class object by receiving and translating form data and passes to service class, if service class excepts certain input in other format like numeric employee number as string employee number then we need to modify servlet component code i.e For the changes that happened in business tier service component we have to modify servlet component of presentation tier b.) If Business Deligate is taken then it gets original form data as VO class object having string inputs and converts VO class object to DTO class object to pass to service class c.) If service class excepts ...

Scripting Tags

JSP Tags/ Elements (1)Scriptlet     Standard syn:-         <%.........%>     xml syn:-        <jsp:scriptlet>...</jsp:scriptlet> Note: All scripting tags allows us to place script code(java code) 1.)The code placed in scriptlet go to _jspService(-,-) of JES class 2.)In a jsp page we can have zero or more scriptlets 3.)We place request processing logics in scriptlets 4.)Variables declared in scriptlets becomes the local variables in _jspService(-,-) of JES class in first.jsp In first.jsp: <% int a=10;  out.println("square:"+(a*a));%> In first_jsp.java(JES): public class first_jsp extends..{     public void _jspService(-,-){        int t=30;        out.println(“Square:”+(t*t));     }  } The code placed in scriptlet can use implicit objects of jsp because implicit objects and the code placed scriptlet goes to _jspService(-...