TY_BCS_A_JAVA_SLIP23



SLIP 23:
Write a program to make use of the following JSP implicit objects.
a.    Out: To display current Date and Time.
b.    Request: to get header information.
c.    Response: to add a cookie.
d.    Config: get the parameters value defined in <init-param>.
e.    Application: get the parameter value defined in <context-param>
/* Slip 23_2 */

<%@page import="java.util.Calendar"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%

    Calendar c = Calendar.getInstance();
   
    int dd = c.get(Calendar.DATE);
    int h = c.get(Calendar.HOUR_OF_DAY);
    int m = c.get(Calendar.MINUTE);
    int s = c.get(Calendar.SECOND);
   
    out.println("\nDate : "+dd+"\nTime : "+h+" : "+m+" : "+s);
   
    String path = request.getContextPath();
    out.println("\nPath : "+path);
   
    Cookie cookie = new Cookie("p", path);
    response.addCookie(cookie);
    out.println("\nCookie Added");
   
    out.println("\nConfig");
    out.println("\n"+config.getServletName());
   
    out.println("\nApplication : ");
    out.println("\n"+application.getServerInfo());
%>

No comments:

Post a Comment