📄 testconverter.java
字号:
import java.io.IOException;
import java.io.PrintWriter;
import javax.naming.InitialContext;
import com.ejbstudy.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*
* Created on 2004-7-3
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
/**
* @author haoyulong
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class testConverter extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
//TODO Method stub generated by Lomboz
response.setContentType("text/html");
PrintWriter out =response.getWriter();
out.println("<html><head><title>the first EJB</title></head>");
try{
InitialContext ctx=new InitialContext();
Object objRef = ctx.lookup("ConverterBean");
// 主接口
ConverterHome
home=(ConverterHome)javax.rmi.PortableRemoteObject.narrow(
objRef,ConverterHome.class);
// 组件接口
Converter bean =home.create();
out.println(bean.toLowerCase("HOW ARE YOU"));
out.println(bean.toUpperCase("how are you"));
}catch(javax.naming.NamingException ne){
out.println("Naming Exception caught:"+ne);
ne.printStackTrace(out);
}catch(javax.ejb.CreateException ce){
out.println("Create Exception caught:"+ce);
ce.printStackTrace(out);
}catch(java.rmi.RemoteException re){
out.println("Remote Exception caught:"+re);
re.printStackTrace(out);
}
out.println("</body></html>");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -