4 JSP - plor10/distributedJava GitHub Wiki
autoFlush These attributes are closely related, and their defaults are “8kb” and true, respectively. They buffered and sent in batches. § errorPage Identifies JSP to forward to when an error occurs. § isErrorPage I ndicates that this JSP is serving as an error page (by default, it is false). § buffer
autoFlush These attributes are closely related, and their defaults are “8kb” and true, respectively. They buffered and sent in batches. § isThreadSafe Defaults to true. Instructs the container that the JSP can safely serve multiple requests simultaneously. If changed to false, the container only serves requests to this JSP one
one. Do not change this. JavaServer Pages (JSP) Directive Including Other JSPs <%@ include file="/path/to/some/ file.jsp " %> This directive statically includes the contents of another jsp file. Changes to that included jsp file will only be realized when the including jsp is re
compiled. This enhances performance over the following option. < jsp:include page="/path/to/some/ page.jsp " /> This directive dynamically includes the contents of another jsp file. JavaServer Pages (JSP) Directive Including Tag Libraries <%@ taglib uri ="http:// java.sun.com / jsp / jstl /core" prefix="c" %> Tag libraries will be discussed later. < jsp:include page="/path/to/some/ page.jsp " /> JavaServer Pages (JSP) Implicit Variables Objects that are created by JSP Engine during translation phase (while translating the JSP document to a Servlet). out javax.servlet.jsp.JspWriter request javax.servlet.http.HttpServletRequest response javax.servlet.http.HttpServletResponse session javax.servlet.http.HttpSession application javax.servlet.ServletContext exception javax.servlet.jsp.JspException page java.lang.Object pageContext javax.servlet.jsp.PageContext config javax.servlet.ServletConfig JavaServer Pages (JSP) Implicit Variables – (Continued) Out: For writing content to the client (browser). <% out.print ("AAA"); %> JavaServer Pages (JSP) Implicit Variables – (Continued) § Request: Access data entered in one JSP document by a JSP document that is called by that document.
Data #1: < br > Data #2: < br > sample.jsp <% String data1= request.getParameter ("d1"); String data2= request.getParameter ("d2"); out. print (" D1: " + data1 + " D2: " + data2); %> JavaServer Pages (JSP) Implicit Variables – (Continued) § Response: Modifies or delays the response which is being sent to the client (browser). § void sendRedirect (String address) Redirects control to a new JSP page. § void sendError ( int status_code , String message) S ends an error response with a code and an error message § void setStatus ( int statuscode ) Used to set the HTTP status to a specific value. JavaServer Pages (JSP) Implicit Variables – (Continued) § Response: Data: sample.jsp <% String data1= request.getParameter ("d1"); if(data1.equals("Cool")) { response.sendRedirect (" coolpage.jsp "); } else { response.sendError (404, data1 + " is not Cool"); } %> JavaServer Pages (JSP) Expression tag Evaluates the expression between the tags, converts the result into String and sends the result back to the client through the response object. <%= Expression %> <% int a=5; int b=7; String val =" AbCdEfGhIjKl "; %> <%= val.substring ( a,b ) + ( a+b )%> JavaServer Pages (JSP) Declaration tag Evaluates the expression between the tags, converts the result into String and sends the result back to the client through the response object. <%= Expression %> <% int a=5; int b=7; String val =" AbCdEfGhIjKl "; %> <%= val.substring ( a,b ) + ( a+b )%>