tailieunhanh - Writing Enterprise Applications with Java™ 2 SDK, Enterprise Edition phần 4

Click Finish. WAR tập tin hộp thoại Properties: • Click Next. Chọn phần hộp thoại Type: • Chọn Servlet (nếu nó chưa được chọn) • Kích Next. Hợp phần chung hộp thoại Properties: • Hãy chắc chắn rằng BonusServlet được chọn cho các lớp Servlet. LESSON 1 BEAN PHẦN SIMPLE | SEPTEMBER 27 2000 33 catch Exception NamingException The try statement in the doGet method creates the CalcBean and BonusBean home interfaces. After calling calcBonus to calculate the bonus the method is called to create an entity bean instance and a corresponding row in the underlying database table. After creating the table the method is called to retrieve the same record by its primary key social security number . Next an HTML page is returned to the browser showing the data originally passed in the calculated bonus and the data retrieved from the database table row. The catch statement catches and handles duplicate primary key values social security numbers . The underlying database table cannot have two rows with the same primary key so if you pass in the same social security number the servlet catches and handles the error before trying to create the entity bean. In the event of a duplicate key the servlet returns an HTML page with the original data passed in the calculated bonus and a duplicate key error message. try Calc theCalculation Retrieve Bonus and Social Security Information String strMult MULTIPLIER Calculate bonus Integer integerMult new Integer strMult multiplier socsec SOCSEC Calculate bonus double bonus theCalculation calc multiplier bonus Create row in table theBonus calc socsec record socsec Display data H1 Bonus Calculation H1 P Soc Sec passed in P P Multiplier passed in multiplier P P Bonus Amount calculated P P Soc Sec retrieved P P Bonus Amount retrieved LESSON 2 A SIMPLE ENTITY BEAN 34 SEPTEMBER 27 2000 P BODY HTML Catch duplicate key error catch .

TỪ KHÓA LIÊN QUAN