📄 testbmp.java
字号:
/*
* Created on 2004-7-2
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package com.ejbstudy;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.FinderException;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author haoyulong
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class TestBMP extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
//TODO Method stub generated by Lomboz
response.setContentType("text/html;charset=gb2312");
PrintWriter out =response.getWriter();
out.println("<html><head><title>BMP EJB test</title></head>");
try{
InitialContext ctx=new InitialContext();
Object objRef = ctx.lookup("BMPAccountBean");
// 主接口
BMPAccountHome
home=(BMPAccountHome)javax.rmi.PortableRemoteObject.narrow(
objRef,BMPAccountHome.class);
BMPAccount bean =home.findByPrimaryKey("1");
//Account bean =home.create("001","song");
out.println("帐号" +":"+bean.getid());
out.println("户名" +":"+bean.getOwnerName());
Double dou= new Double(bean.getBalance());
out.println("余额" +":"+dou.toString());
out.println("调用方法:bean.deposit(100.00)");
bean.deposit(100.00);
dou= new Double(bean.getBalance());
out.println("余额" +":"+dou.toString());
}
catch (FinderException e){
out.println(e.toString());
}
/*catch (CreateException e){
out.println(e.toString());
}*/
catch(javax.naming.NamingException ne){
out.println("Naming Exception caught:"+ne);
ne.printStackTrace(out);
}catch(java.rmi.RemoteException re){
out.println("Remote Exception caught:"+re);
re.printStackTrace(out);
}
catch (Exception e){
out.println(e.toString());
}
out.println("</body></html>");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -