Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.airline.controllers;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.ejb.EJB;
- import javax.naming.Context;
- import javax.naming.InitialContext;
- import javax.naming.NamingException;
- import javax.servlet.ServletException;
- import javax.servlet.annotation.WebServlet;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.airline.service.FlightService;
- /**
- * Servlet implementation class FlightDetails
- */
- @WebServlet("/FlightDetails")
- public class FlightDetails extends HttpServlet {
- private static final long serialVersionUID = 1L;
- @EJB
- private FlightService fs;// = null;
- /**
- * @see HttpServlet#HttpServlet()
- */
- public FlightDetails() {
- super();
- // TODO Auto-generated constructor stub
- }
- /**
- * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
- * response)
- */
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- PrintWriter out = response.getWriter();
- out.println("The flight details servlet has been called...");
- // try {
- // Context context = new InitialContext();
- // fs = (FlightService) context.lookup("java:global/ejb2/FlightService!com.airline.service.FlightService");
- // }
- // catch (NamingException e){
- // System.out.println("Naming exception has occurred | lookup: flightService");
- // e.printStackTrace();
- // }
- if (fs != null){
- fs.setId(1);
- out.println("Flight details: " + new FlightService());
- }
- }
- /**
- * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
- * response)
- */
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- // TODO Auto-generated method stub
- doGet(request, response);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement