Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c) JSP lifecycle is defined as translation of JSP page into servlet as a JSP page needs to be converted into servlet first in order

image text in transcribed

image text in transcribed

image text in transcribed

c) JSP lifecycle is defined as translation of JSP page into servlet as a JSP page needs to be converted into servlet first in order to process the service requests. Assuming that you have corrected Program 2.1 above. (6 marks) (i) Analyse Program 2.4 below and map the code of JSP page in Program 2.1 (scriptingl.jsp) into Servlet in Program 2.4 (scriptingl_jsp.java). Fill in the blanks below. Note: Write Not Applicable where necessary. Based on your answer in (i), justify your answer. // Program 2.4 - scriptingl_jsp.java package org.apache.jsp; import javax.servlet.; import javax.servlet.http.*; import javax.servlet.jsp.*; public final class scripting1_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime. JspSourceDependent { (answer for Q2.c.i.1) private static final JapFactory _jspxFactory JspFactory.getDefaultFactory(); private static java.util.List _jspx_dependants; private org.glassfish.jsp.api.ResourceInjector jspx_resource Injector; public java.util.List getDependants () { return jspx_dependants; } public void jspService (HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page this; JspWriter jspx_out = null; PageContext jspx_page_context = null; try { response.setContentType ("text/html; charset=UTF-8"); response.setHeader ("X-Powered-By", "JSP/2.3"); pageContext _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); jspx out = out; jspx_resourceInjector (org.glassfish.jsp.api.Resource Injector) application.getAttribute("com.sun.appserv.jsp.resource. injector"); out.write(" "); out.write(" "); out.write(" "); out.write(" "); out.write(" "); out.write(" "); out.write(" "); out.write(" JSP Page "); out.write(" "); out.write(" "); out.write(" "); (answer for Q2.c.i.2) out.write(" "); out.write(" "); (answer for Q2.c.i.3) out.write(" "); out.write(" (answer for Q2.c.i.4) out.write(" "); out.write(" "); out.write(" "); out.write(" "); out.write(" "); } catch (Throwable t) { if (!(t instanceof Skip PageException)) { out = jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (jspx_page_context != null) jspx_page_context.handlePageException (t); else throw new ServletException(t); } } finally _jspxFactory.releasePageContext_jspx_page_context); } } c) JSP lifecycle is defined as translation of JSP page into servlet as a JSP page needs to be converted into servlet first in order to process the service requests. Assuming that you have corrected Program 2.1 above. (6 marks) (i) Analyse Program 2.4 below and map the code of JSP page in Program 2.1 (scriptingl.jsp) into Servlet in Program 2.4 (scriptingl_jsp.java). Fill in the blanks below. Note: Write Not Applicable where necessary. Based on your answer in (i), justify your answer. // Program 2.4 - scriptingl_jsp.java package org.apache.jsp; import javax.servlet.; import javax.servlet.http.*; import javax.servlet.jsp.*; public final class scripting1_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime. JspSourceDependent { (answer for Q2.c.i.1) private static final JapFactory _jspxFactory JspFactory.getDefaultFactory(); private static java.util.List _jspx_dependants; private org.glassfish.jsp.api.ResourceInjector jspx_resource Injector; public java.util.List getDependants () { return jspx_dependants; } public void jspService (HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page this; JspWriter jspx_out = null; PageContext jspx_page_context = null; try { response.setContentType ("text/html; charset=UTF-8"); response.setHeader ("X-Powered-By", "JSP/2.3"); pageContext _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); jspx out = out; jspx_resourceInjector (org.glassfish.jsp.api.Resource Injector) application.getAttribute("com.sun.appserv.jsp.resource. injector"); out.write(" "); out.write(" "); out.write(" "); out.write(" "); out.write(" "); out.write(" "); out.write(" "); out.write(" JSP Page "); out.write(" "); out.write(" "); out.write(" "); (answer for Q2.c.i.2) out.write(" "); out.write(" "); (answer for Q2.c.i.3) out.write(" "); out.write(" (answer for Q2.c.i.4) out.write(" "); out.write(" "); out.write(" "); out.write(" "); out.write(" "); } catch (Throwable t) { if (!(t instanceof Skip PageException)) { out = jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (jspx_page_context != null) jspx_page_context.handlePageException (t); else throw new ServletException(t); } } finally _jspxFactory.releasePageContext_jspx_page_context); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

1. Identify six different types of history.

Answered: 1 week ago