Enterprise application development is the process of building complex, customized software for large organizations to automate processes, improve efficiency, and streamline operations across departments like CRM, ERP, and supply chain management
Size: 70.89 KB
Language: en
Added: Aug 31, 2025
Slides: 17 pages
Slide Content
Enterprise Application Development With Java EE Saturday, May 27, 2023 1
JSP Implicit Objects These objects are created by JSP Engine during translation phase (while translating JSP to Servlet). They are being created inside service method so we can directly use them within Scriptlet without initializing and declaring them. There are total 9 implicit objects available in JSP. Saturday, May 27, 2023 2
Implicit Objects and their corresponding classes: Saturday, May 27, 2023 3 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
Implicit Object Out Saturday, May 27, 2023 4 This is used for writing content to the client (browser). It has several methods which can be used for properly formatting output message to the browser and for dealing with the buffer. Methods of OUT Implicit Object void print() void println () void newLine () void clear() void clearBuffer () void flush() boolean isAutoFlush () int getBufferSize () int getRemaining ()
Implicit Object Out Saturday, May 27, 2023 5 void newLine () : This method adds a new line to the output. Example – out.print (“This will write content without a new line”); out.newLine (); out.print (“I’m just an another print statement”); void clear() : It clears the output buffer without even letting it write the buffer content to the client. . This is how it can be called: out.clear (); void clearBuffer () : This method is similar to the clear() method. The only difference between them is that when we invoke out.clear () on an already flushed buffer it throws an exception, however out.clearBuffer () doesn’t.
Implicit Object Out Saturday, May 27, 2023 6 void flush() : This method also clears the buffer just like clear() method but it forces it to write the content to the output before flushing it. boolean isAutoFlush () : It returns a Boolean value true/false. It is used to check whether the buffer is automatically flushed or not. int getBufferSize () : This method returns the size of output buffer in bytes. int getRemaining () : It returns the number of bytes remaining before hitting the buffer overflow condition.
Implicit Object Request Saturday, May 27, 2023 7 The main purpose of request implicit object is to get the data on a JSP page which has been entered by user on the previous JSP page. While dealing with login and signup forms in JSP we often prompts user to fill in those details, this object is then used to get those entered details on an another JSP page (action page) for validation and other purposes.
Implicit Object Request Saturday, May 27, 2023 8 getParameter (String name) – This method is used to get the value of a request’s parameter. For example at login page user enters user-id and password and the login page gets redirected to user information page, then using request.getParameter we can get the value of user-id and password which user has input at the login page. String Uid = request.getParameter ("user-id"); String Pass= request.getParameter ("password"); getParameterNames () – It returns enumeration of all the parameter names associated to the request. Enumeration e= request.getParameterNames (); getParameterValues (String name) – It returns the array of parameter values. String[] allpasswords = request.getParameterValues ("password");
Implicit Object Request Saturday, May 27, 2023 9 getAttribute (String name) – Used to get the attribute value. request.getAttribute (“admin”) would give you the value of attribute admin. getAttributeNames () – It is generally used to get the attribute names associated to the current session. It returns the enumeration of attribute names present in session. Enumerator e = request.getAttributeNames (); setAttribute ( String,Object ) – It assigns an object’s value to the attribute. For example I have an attribute password and a String object str which has a value “admin” then calling request.setAttribute (“password”, str) would assign a value admin to the attribute password . removeAttribute (String) – By using this method a attribute can be removed and cannot be used further. For example If you have a statement request.removeAttribute (“ userid ”) on a JSP page then the userid attribute would be completely removed and request.getAttribute (“ userid ”) would return NULL if used after the removeAttribute method. getCookies () – It returns an array of cookie objects received from the client. This method is mainly used when dealing with cookies in JSP.
Implicit Object Request Saturday, May 27, 2023 10 getHeader (String name) – This method is used to get the header information of the request. getHeaderNames () – Returns enumerator of all header names. Below code snippet would display all the header names associated with the request. Enumeration e = request.getHeaderNames (); while ( enumeration.hasMoreElements ()) { String str = (String) e.nextElement (); out.println (str); } getRequestURI () – This method ( request.getRequestURI ()) returns the URL of current JSP page. getMethod () – It returns HTTP request method. request.getMethod (). For example it will return GET for a Get request and POST for a Post Request. getQueryString () – Used for getting the query string associated to the JSP page URL. It is the string associated to the URL after question mark sign (?).
Implicit Object Response Saturday, May 27, 2023 12 It is an instance of javax.servlet.http.HttpServletRequest and mainly used for modifying the response which is being sent to the browser after processing the client’s request. void setContentType (String type) – This method tells browser, the type of response data by setting up the MIME type and character encoding. The information sets by this method helps browser to interpret the response. Example response.setContentType ("text/html"); response.setContentType ("image/gif"); response.setContentType ("image/ png "); response.setContentType ("application/pdf");
Implicit Object Response Saturday, May 27, 2023 13 void sendRedirect (String address) – It redirects the control to a new JSP page. For example, When the browser would detect the below statement, it would be redirected to the beginnersbook.com from the current JSP page. response.sendRedirect ("http:// beginnersbook.com "); void addHeader (String name, String value) – addHeader method adds a header to the response, basically it includes a header name and it’s value. For example – The below statement will include a header “Site” in the response with value “ BeginnersBook.com ”. response.addHeader ("Site", " BeginnersBook.com "); void setHeader (String name, String value) – It sets the header value. This method overrides the current value of header with the new value. Let’s say I’m modifying the value of Header “ Site “. The below statement would modify the current value BeginnersBook.com to a new value BB.com response.setHeader ("Site", " BB.com ");
Implicit Object Response Saturday, May 27, 2023 14 boolean containsHeader (String name) – It returns a Boolean value true/false. It basically checks the whether the header is present in the response or not. For example – Above, in the addHeader method example we have added a Site Header in response so the below statement would return true. response.containsHeader ("Site"); void addCookie (Cookie cookie) – This method adds a cookie to the response. The below statements would add 2 Cookies Author and Siteinfo to the response. response.addCookie (Cookie Author); response.addCookie (Cookie Siteinfo ); void sendError (int status_code , String message) – It is used to send error response with a code and an error message. For example – response.sendError (404, "Page not found error");
Implicit Object Response Saturday, May 27, 2023 15 boolean isCommitted () -It checks whether the Http Response has been sent to the client, if yes then it returns true else it gives false. <% if( response.isCommited ()) { <%--do something --%> }else { <%--do something else --%> } %> void setStatus (int statuscode ) – This method is used to set the HTTP status to a given value. For example, the below statement would set HTTP response code to 404 (Page not found). response.setStatus (404);