Advertisement
Guest User

FlightDetails.java

a guest
Mar 8th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1. package com.airline.controllers;
  2.  
  3. import java.io.IOException;
  4. import java.io.PrintWriter;
  5.  
  6. import javax.ejb.EJB;
  7. import javax.naming.Context;
  8. import javax.naming.InitialContext;
  9. import javax.naming.NamingException;
  10. import javax.servlet.ServletException;
  11. import javax.servlet.annotation.WebServlet;
  12. import javax.servlet.http.HttpServlet;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15.  
  16. import com.airline.service.FlightService;
  17.  
  18. /**
  19.  * Servlet implementation class FlightDetails
  20.  */
  21. @WebServlet("/FlightDetails")
  22. public class FlightDetails extends HttpServlet {
  23.     private static final long serialVersionUID = 1L;
  24.  
  25.     @EJB
  26.     private FlightService fs;// = null;
  27.    
  28.     /**
  29.      * @see HttpServlet#HttpServlet()
  30.      */
  31.     public FlightDetails() {
  32.         super();
  33.         // TODO Auto-generated constructor stub
  34.     }
  35.  
  36.     /**
  37.      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
  38.      *      response)
  39.      */
  40.     protected void doGet(HttpServletRequest request, HttpServletResponse response)
  41.             throws ServletException, IOException {
  42.  
  43.         PrintWriter out = response.getWriter();
  44.         out.println("The flight details servlet has been called...");
  45.        
  46. //      try {
  47. //          Context context = new InitialContext();
  48. //          fs = (FlightService) context.lookup("java:global/ejb2/FlightService!com.airline.service.FlightService");           
  49. //      }
  50. //      catch (NamingException e){
  51. //          System.out.println("Naming exception has occurred | lookup: flightService");
  52. //          e.printStackTrace();
  53. //      }
  54.        
  55.         if (fs != null){
  56.             fs.setId(1);
  57.             out.println("Flight details: " + new FlightService());
  58.         }
  59.  
  60.     }
  61.  
  62.     /**
  63.      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
  64.      *      response)
  65.      */
  66.     protected void doPost(HttpServletRequest request, HttpServletResponse response)
  67.             throws ServletException, IOException {
  68.         // TODO Auto-generated method stub
  69.         doGet(request, response);
  70.     }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement