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

📄 searchproduct.java

📁 一个完整的代码管理系统的源代码
💻 JAVA
字号:
package hunnu.edu.cn.product.servlet;

import java.io.IOException;


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


import hunnu.edu.cn.product.common.splitPages.PagedStatementOracleImpl;
import hunnu.edu.cn.product.common.splitPages.RowSetPage; 





public class SearchProduct extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Constructor of the object.
	 */
	public SearchProduct() {
		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 {
		   response.setContentType("text/html;charset=gbk");
		   String exit= request.getParameter("exit");
		   HttpSession session;
		   if(exit!=null){
			   HttpSession oldSession = request.getSession(false);
			   if(oldSession!=null){
				   oldSession.invalidate();
			   }
			    session=request.getSession(true);
			   
			   
		   }
		   else{
		      session = request.getSession(true);
		   }
		   String sql = request.getParameter("sql");
		   String type = request.getParameter("type");
		   String str=null;
		   String page;
		   PagedStatementOracleImpl pso =null;
		   int pageNo;
		  if(type!=null){
			  session.removeAttribute("productsql");
		  }
		
		   if(sql==null){
			  
			    str = (String)session.getAttribute("productsql");
    	      
    	        if(str == null){
    		         String user_group_id = (String)session.getAttribute("user_group_id");
		             if(user_group_id==null){ 
			                    str ="select tt.pro_id,tt.pro_name,bb.user_login, pro_comnt, counter,backcount ,avglevel from tb_product tt left outer join tb_user_mst bb on tt.in_user_id=bb.user_id left outer join tb_download_file ff on tt.pro_id=ff.pro_id left outer join tb_feedback_mst dd on tt.pro_id = dd.pro_id  where  tt.pro_flg=1";
		                   }
		             else {
		            	 
		            	 if(user_group_id.equals("1"))
		            		str="select tt.pro_id,tt.pro_flg,tt.pro_name,bb.user_login, pro_comnt, counter,backcount ,avglevel from tb_product tt left outer join tb_user_mst bb on tt.in_user_id=bb.user_id left outer join tb_download_file ff on tt.pro_id=ff.pro_id left outer join tb_feedback_mst dd on tt.pro_id = dd.pro_id "; 
		            	 else{
		            		 String user_login=(String)session.getAttribute("user_name");
			               str ="select tt.pro_id,tt.pro_name,bb.user_login, pro_comnt, counter,backcount ,avglevel from tb_product tt left outer join tb_user_mst bb on tt.in_user_id=bb.user_id left outer join tb_download_file ff on tt.pro_id=ff.pro_id left outer join tb_feedback_mst dd on tt.pro_id = dd.pro_id  where  tt.pro_flg=1 and bb.user_login='"+user_login+"'";
		                  
		            	 }
		             }
    	             }
		   }
		  
		else{
			if(sql.equals("")){
				String user_group_id = (String)session.getAttribute("user_group_id");
				if(user_group_id!=null)
					if(user_group_id.equals("1"))
						str="select tt.pro_id,tt.pro_flg,tt.pro_name,bb.user_login, pro_comnt, counter,backcount ,avglevel from tb_product tt left outer join tb_user_mst bb on tt.in_user_id=bb.user_id left outer join tb_download_file ff on tt.pro_id=ff.pro_id left outer join tb_feedback_mst dd on tt.pro_id = dd.pro_id "; 
	            	
					else 
						str ="select tt.pro_id,tt.pro_name,bb.user_login, pro_comnt, counter,backcount ,avglevel from tb_product tt left outer join tb_user_mst bb on tt.in_user_id=bb.user_id left outer join tb_download_file ff on tt.pro_id=ff.pro_id left outer join tb_feedback_mst dd on tt.pro_id = dd.pro_id  where  tt.pro_flg=1";
				 }
			else
			   str = "select tt.pro_id,tt.pro_name,bb.user_login, pro_comnt, counter,backcount ,avglevel from tb_product tt left outer join tb_user_mst bb on tt.in_user_id=bb.user_id left outer join tb_download_file ff on tt.pro_id=ff.pro_id left outer join tb_feedback_mst dd on tt.pro_id = dd.pro_id  where  tt.pro_flg=1 and  "+sql;
			   
			   
			   
		   }
		
		  
		    session.setAttribute("productsql",str);
		   
		    page=(String)request.getParameter("page");
		    
		  if(page!=null){
		       pageNo =Integer.parseInt(page);
		      
		        pso =  new PagedStatementOracleImpl(str,pageNo);
	       }
		  else {
		    pso =  new PagedStatementOracleImpl(str,1);
		   }
		  
		
	        try{
	        	RowSetPage rsp  = pso.executeQuery();
	            request.setAttribute("rowsetpage",rsp )	;
	        	RequestDispatcher rd; 
	    		rd=request.getRequestDispatcher("SelectPages.jsp"); 
	    		rd.forward(request,response); 
	          
	           
	        
	     }catch (Exception e){
	        	
	        	System.out.print(e.getMessage());
	        }

	}

	/**
	 * 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 {

		    doGet(request,response);
	}

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

}

⌨️ 快捷键说明

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