Tuesday, 1 December 2015

WCD-LAB @HOME 5-Ans 2

WCD-LAB @HOME 5-Ans 2



2. In the ExoticaTravels Web application, if any changes are made to the list of hotel and cab servicers name, the application code needs to be updated to reflect these changes. Therefore, you need to enhance the functionality of the ExoticaTravels Web application such that any changes made to the hotel and cab servicers list does not affect the application.

Note: To perform this exercise, you need to use the solution created in Exercise 01 of Chapter 04.


import java.io.IOException;
impot\rtjava.io.PrintWriter;
impot javax.Servlet.ServletException;
import javax.Servlet.annotation.WebServlet;
import javax,Servler.http.HttpServlet;
import javax.servlet.http.HttpServleltRequest;
import javax.Servlet.http.HttpServletResponse;
import javax.Servlet.http.HttpSession;

 public class HotelBookingServelt extends HttpServelt
    {
       protected void ProcessRequest(HttpServletRequest
request ,HttpServeltResponse response)
            throw ServletException.IOException
            {
   response .setContentTypes("text/html;charset=UTF-8");
   printWriter out = response.getWriter();
   HttpSession session=request.getSession();
   string hotelNames=this.getInitParameter
("HotelNames");
                      String hotelNameSplit[]=hotelName.split(" , ");
      try
                  {
                      String destination=request.getParameter
  ("destionation");
                          session.setAttribute("destination",
   destination);
                     out.println("<title>Tour package Booking
page</title>");
 out.println("<div align=right'>);
                    out.println("<a
href='LogoutServlet'>Logout</a>");
                   out.println("</div");
                    out.println("<tabel>");
                   out.println("<from
action='CabBookingServlet'>");
                out.println("<tr><td><h3>Tour package
 Booking</h3></td></tr>");
                     out.println("<tr><td>Select ahotel</td>");
                     out.println("<td><select name='hotel'>");
                     for(int i=0;<hotelNameSplit.length;i++)
                     out.println("option value=' "+hotelNameSplit
[i]+" '>"+hotelNameSplit[i]+"</option");
               
                     out.println</select></h1></td>");
                     out.println("<tr><td>Number of days</td>");
name='noofdays'></td></tr>");
                      out.println("<tr><td><input types='submit'
value='next'></td>");
               out.println("</form>");
               out.println("<from
action='Tourpackagepage.jsp'>");
                       out.println("<td><input type='submit'
value='back'></td></tr>");
                  out.println("</form>");
                   out.println("<?table>");
                }
                      finally
                                 {
                                           out.close();
                    }
    }
@Override
   protected void goGet(HttpServletRequest request,
httpServletResponse response)
       throws ServletException.IOException
         {
     processRequest(request.response);
   }
@override
    protected void doPost(HttpServletRequest request,
HttpServletResponse response)
                  throw ServletException, IOException
        {
              processRequesr(request ,response);
                   }

   @override
   public String getServletInfo()
      {
         return"short description";
       }
}


No comments:

Post a Comment