?? showbalance.java
字號:
package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Servlet that reads a customer ID and displays
* information on the account balance of the customer
* who has that ID.
* <p>
* From <a href="http://courses.coreservlets.com/Course-Materials/">the
* coreservlets.com tutorials on servlets, JSP, Struts, JSF, Ajax, GWT,
* Spring, Hibernate/JPA, and Java programming</a>.
*/
public class ShowBalance extends HttpServlet {
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
BankCustomer customer =
BankCustomerLookup.getCustomer(request.getParameter("id"));
String address;
if (customer == null) {
address = "/WEB-INF/bank-account/UnknownCustomer.jsp";
} else if (customer.getBalance() < 0) {
address = "/WEB-INF/bank-account/NegativeBalance.jsp";
request.setAttribute("badCustomer", customer);
} else if (customer.getBalance() < 10000) {
address = "/WEB-INF/bank-account/NormalBalance.jsp";
request.setAttribute("regularCustomer", customer);
} else {
address = "/WEB-INF/bank-account/HighBalance.jsp";
request.setAttribute("eliteCustomer", customer);
}
RequestDispatcher dispatcher =
request.getRequestDispatcher(address);
dispatcher.forward(request, response);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -