TestLocalInterface.java
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:2k
源码类别:
Java编程
开发平台:
Java
- package meetings;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import java.io.*;
- import java.util.*;
- /**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: </p>
- * @author not attributable
- * @version 1.0
- */
- import javax.naming.*;
- import com.cwj.meetings.*;
- import javax.ejb.*;
- public class TestLocalInterface extends HttpServlet {
- private static final String CONTENT_TYPE = "text/html; charset=GB2312";
- //Initialize global variables
- public void init() throws ServletException {
- }
- //Process the HTTP Get request
- public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- response.setContentType(CONTENT_TYPE);
- PrintWriter out = response.getWriter();
- out.println("<html>");
- out.println("<head><title>TestLocalInterface</title></head>");
- out.println("<body bgcolor="#ffffff">");
- try {
- Context context = new InitialContext();
- HolidayCalendarLocalHome lh = (HolidayCalendarLocalHome) context.lookup(
- "Holiday/HolidayCalendarLocal");
- //
- // System.out.println(lh);
- HolidayCalendarLocal hcal = lh.create();
- if (hcal.isCompanyHoliday(new java.util.Date())) {
- out.println("Today is a holiday :-)");
- }
- else {
- out.println("Today is a working day :-(");
- }
- }
- catch (CreateException ex) {
- }
- catch (NamingException ex) {
- }
- out.println("<p>以上内容是Local Interface访问EJB执行结果.</p>");
- out.println("</body></html>");
- }
- //Clean up resources
- public void destroy() {
- }
- }