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

📄 buyebook.jsp

📁 模仿当当网的网上书城
💻 JSP
字号:
<?xml version="1.0" encoding="UTF-8" ?><%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%>
<%@page import="java.util.*" %>
<%@page import="shop.*" %>
<%@page import="javax.servlet.http.HttpSession" %>
<%@page import="java.sql.*"%>

<% boolean login=false;
   request.setCharacterEncoding("UTF-8");
   HttpSession usersession = request.getSession(true);
   String bookid=request.getParameter("bid");   
   String type=request.getParameter("type");  
   String[] bookids=new String[50];
   
   for(int temp=0;temp<50;temp++){
	   bookids[temp]="0";	  
   }
   if(usersession.getAttribute("islogin")==null){
	   
   }else {
	   if(((Boolean)usersession.getAttribute("islogin"))==true){
		   login=true;
		   if(type.equals("1")){
			   if(usersession.getAttribute("buyebook")!=null){
				   String bbooks[]=(String[])usersession.getAttribute("buyebook");
				   int i=0;
				   
				   while(!(bbooks[i].equals("0"))){
					   i++;
				   }
				   bbooks[i]=bookid;				   
			       usersession.setAttribute("buyebook",bbooks);
			       bookids=bbooks;
			   }else{
				   bookids[0]=bookid;				   
				   usersession.setAttribute("buyebook",bookids);
				   
			   }
		   }
		   
		   if(type.equals("-1")){
			   int temp2=49;
			   int temp;
			   String bbooks[]=(String[])usersession.getAttribute("buyebook");
			   for(temp=0;temp<49;){
				   if(bbooks[temp].equals(bookid)){
					   bbooks[temp]="0";
					   temp2=temp;					   
					   break;
				   }
				   temp++;
			   }			   
			   out.println(temp2);
			   for(temp=temp2;temp<49-temp2;){				   
				   bbooks[temp]=bbooks[temp+1];
				   temp++;
			   }
			   usersession.setAttribute("buyebook",bbooks);
			   bookids=bbooks;
		   }
		   if(type.equals("0")){
			   if(usersession.getAttribute("buyebook")!=null){
			       bookids=(String[])usersession.getAttribute("buyebook");
			   }
		   }
	   }
   }   
  %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link rel="stylesheet" type="text/css" href="web2.css" />
<title>娆㈣繋鏉ュ埌缃戜笂涔﹀煄</title></head><body>
 <%if(login==true){%><div id="wrap">
    <div id="header"><h1>璐

⌨️ 快捷键说明

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