⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serchservlet.java

📁 提供房屋出租信息
💻 JAVA
字号:
package cwnu.com.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cwnu.com.rentInfo.*;
import cwnu.com.saleInfo.*;;

public class serchservlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public serchservlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	       String region = new String(request.getParameter("region").getBytes("ISO-8859-1"),"GBK");
	       String area = request.getParameter("area");
	       String useType = new String(request.getParameter("useType").getBytes("ISO-8859-1"),"GBK");
	       String price = request.getParameter("price");
	       String style = new String(request.getParameter("style").getBytes("ISO-8859-1"),"GBK");
	       String type = request.getParameter("type");
	       String[] splitarea = area.split("-");
	       String[] splitprice = price.split("-");
	       if(type.equals("rent"))
	       {
	    	
	    	   ArrayList<rentInfoVo> myrentlist = new ArrayList<rentInfoVo>();
	    	   ArrayList<rentInfoVo> rentlist = (ArrayList<rentInfoVo>)request.getSession().getAttribute("rentList");
	    	   
	    	   for(int i=0;i<rentlist.size();i++)//租房信息搜索
	    	   {
	    		   if(rentlist.get(1).getRegion().equals(region))
	    		   {
	    			   
	    			   System.out.println(rentlist.get(1).getRegion());
	    			   if(Integer.parseInt(rentlist.get(i).getArea())>Integer.parseInt(splitarea[0])&&Integer.parseInt(rentlist.get(i).getArea())<Integer.parseInt(splitarea[1]))
	    			   {
	    				   System.out.println(rentlist.get(i).getArea());
	    				   System.out.println(rentlist.get(i).getUseType());
	    				   System.out.println(useType);
	    				   if(rentlist.get(i).getUseType().equals(useType))
	    				   {
	    					   System.out.println(rentlist.get(i).getUseType());
	    					   if(Integer.parseInt(rentlist.get(i).getRentPrice())>Integer.parseInt(splitprice[0])&&
	    							   Integer.parseInt(rentlist.get(i).getRentPrice())<Integer.parseInt(splitprice[1]))
	    					   {
	    						   System.out.println(rentlist.get(i).getRentPrice());
	    						   if(rentlist.get(i).getHouseType().equals(style))
	    						   {
	    							   System.out.println(rentlist.get(i).getHouseType());
	    							   myrentlist.add(rentlist.get(i));
	    						   }
	    					   }
	    				   }
	    			   }
	    		   }
	    	   }
	    	   
	    	   request.getSession(true).setAttribute("myrentlist", myrentlist);
	    	   response.sendRedirect("Jsp/searchrentresult.jsp");
	    	   
	       }else if(type.equals("sale"))//售房信息搜索
	       {System.out.println(region);
	    	   setSInfoList objsale = new setSInfoList();
	    	   ArrayList<saleInfoVo> mysalelist = new ArrayList<saleInfoVo>();	    	   
	    	   ArrayList<saleInfoVo> saleList = (ArrayList<saleInfoVo>)request.getSession().getAttribute("saleList");
	    	   

	    	   for(int i=0;i<saleList.size();i++)//售房信息搜索
	    	   {
	    		   if(saleList.get(i).getRegion().equals(region))
	    		   {
	    			   
	    			   System.out.println(saleList.get(i).getRegion());
	    			   if(Integer.parseInt(saleList.get(i).getArea())>Integer.parseInt(splitarea[0])&&Integer.parseInt(saleList.get(i).getArea())<Integer.parseInt(splitarea[1]))
	    			   {
	    				   System.out.println(saleList.get(i).getArea());
	    				   System.out.println(saleList.get(i).getUseType());
	    				   System.out.println(useType);
	    				   if(saleList.get(i).getUseType().equals(useType))
	    				   {
	    					   System.out.println(saleList.get(i).getUseType());
	    					   if(Integer.parseInt(saleList.get(i).getPrice())>Integer.parseInt(splitprice[0])&&
	    							   Integer.parseInt(saleList.get(i).getPrice())<Integer.parseInt(splitprice[1]))
	    					   {
	    						   System.out.println(saleList.get(i).getPrice());
	    						   if(saleList.get(i).getHouseType().equals(style))
	    						   {
	    							   System.out.println(saleList.get(i).getHouseType());
	    							   mysalelist.add(saleList.get(i));
	    						   }
	    					   }
	    				   }
	    			   }
	    		   }
	           }
	    	   
	    	   request.getSession(true).setAttribute("mysalelist", mysalelist);
	    	   response.sendRedirect("Jsp/searchsaleresult.jsp");
	    	   
	    }
	       
	       
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

⌨️ 快捷键说明

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