getbids.java

来自「J2EE开发与Weblogic一书中的源代码」· Java 代码 · 共 40 行

JAVA
40
字号
package webauction.web.action;

import java.io.IOException;
import java.rmi.RemoteException;
import javax.servlet.*;
import javax.servlet.http.*;
import webauction.ejb.*;
import webauction.web.WebConstants;
import webauction.web.javabean.*;

public class GetBids extends HttpServlet {

    public void service(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException {
        ServletContext sc = getServletContext();
        WebAuction webAuction =
            (WebAuction) sc.getAttribute(WebConstants.SC_ATTRIB_WEBAUCTION);
        try {
            BidValueHolder[] bids =
                webAuction.getBidsForUser(req.getRemoteUser());
            BidsListBean bidsBean = new BidsListBean();
            bidsBean.setBids(bids);
            bidsBean.setUserName(req.getRemoteUser());
            req.setAttribute("bids", bidsBean);

            PageBean pageBean = new PageBean();
            pageBean.setTitle("WebLogic Auction");
            pageBean.setBody("jsp/listbids.jsp");
            req.setAttribute("pageBean", pageBean);
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (NoSuchUserException e) {
            e.printStackTrace();
        }

        RequestDispatcher rd = sc.getNamedDispatcher("template");
        rd.forward(req, res);
        return;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?