📄 addc.java
字号:
package testejb;import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;import javax.naming.*;import javax.rmi.PortableRemoteObject;import java.lang.*;public class addc extends HttpServlet implements SingleThreadModel{ //Initialize global variables private baseclass basebean; private Context context; private int allcustomer=0; private EmployeeCustomerHome employeeCustomerHome; private EmployeeCustomer employeeCustomer; public void init() throws ServletException { } //Process the HTTP Post request public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try{ basebean=new baseclass(); context=basebean.getContext(); Object ref = context.lookup("EmployeeCustomerBean"); employeeCustomerHome = (EmployeeCustomerHome) PortableRemoteObject.narrow(ref, EmployeeCustomerHome.class); employeeCustomer=employeeCustomerHome.create(); Vector temp=employeeCustomer.display(); allcustomer=temp.size()+1; Integer total=new Integer(allcustomer); String id=total.toString(); String name=trans(request.getParameter("name")); String addr=trans(request.getParameter("addr")); String contact=trans(request.getParameter("contact")); String phone=request.getParameter("phone"); String email=request.getParameter("email"); HttpSession session=request.getSession(false); String representid=session.getAttribute("id").toString(); employeeCustomer.addCustomer(id,name,addr,contact,phone,email,representid); RequestDispatcher requestDispather=request.getRequestDispatcher("/customer.jsp"); requestDispather.forward(request,response); } catch (Exception e) { RequestDispatcher requestDispather=request.getRequestDispatcher("/error.jsp"); requestDispather.forward(request,response);} } //Clean up resources public void destroy() { } private String trans(String chi) { String result=null; byte temp[]; try{ temp=chi.getBytes("iso-8859-1"); result=new String(temp); } catch(UnsupportedEncodingException e) {e.printStackTrace();} return result; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -