searchaction.java~10~

来自「使用J2EE实现了软件园的下载和上传功能」· JAVA~10~ 代码 · 共 49 行

JAVA~10~
49
字号
package software;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import javax.naming.*;
import javax.rmi.*;
import java.util.*;
public class searchAction extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=GB2312";

    //Initialize global variables
    public void init() throws ServletException {
    }

    //Process the HTTP Get request
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        response.setContentType(CONTENT_TYPE);
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head><title>searchAction</title></head>");
        out.println("<body bgcolor=\"#ffffff\">");
        out.println("AAAAAAAAAAAA");
        //String keyword="%"+new String(request.getParameter("keyword").getBytes("iso8859-1"),"gb2312")+"%";
        try{
            Context ic=new InitialContext();
            Object obj=ic.lookup("softwareRemote");
            softwareRemoteHome home=(softwareRemoteHome)PortableRemoteObject.narrow(obj,softwareRemoteHome.class);
            Collection c=home.findSearch("ddd%");
            Iterator i=c.iterator();
            while(i.hasNext()){
                softwareRemote s=(softwareRemote)i.next();
                out.println(s.getSoftwareName()+"||");
            }
        }catch(Exception ex){
            ex.printStackTrace();
        }
        out.println("</body>");
        out.println("</html>");
        out.close();
    }

    //Clean up resources
    public void destroy() {
    }
}

⌨️ 快捷键说明

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