TY_BCA_2015_ADV_JAVA_15MARKS_SLIP16



SLIP16:  Write a JSP page, which accepts user name in a text box and greets the user according to the time on server machine.

SLIP16_FIRST..jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <body>
        <form action="Slip16.jsp" method="post">
            Enter Your Name : <input type="text" name="name"><br>
           
            <input type="submit" value="Submit">
        </form>
    </body>
</html>


SLIP16.jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%

    String name = request.getParameter("name");
   
   Calendar rightnow = Calendar.getInstance();
   int time = rightnow.get(Calendar.HOUR_OF_DAY);
  
    if(time > 0 && time <= 12)
    {
        out.println("Good Morning"+name);
    }
      else if(time < 12 && time >=16)
      {
          out.println("Good Afternoon"+name);
      }
      else
      {
          out.println("Good Night"+name);
      }
%>

No comments:

Post a Comment