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

📄 shopping_cart.jsp

📁 《J2EE专业项目实例开发》源代码
💻 JSP
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<title>Shopping Cart Page</title>
</head>


<body bgcolor="#C0C0C0" topmargin="0" background="http:\\localhost:8000\music\Background.bmp" >

<table border="0" width="100%">
  <tr>
    <td width="100%">
      <table border="0" width="97%" height="19">
        <tr>
          <td width="18%" height="13" valign="middle" align="right">
      <font face="Arial" size="5" color="#800000"><b><i>eMusicWorld-----&gt; The World of Music</i></b></font>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>


<form method="get" action="http://localhost:8000/music/update_wishlist.jsp">

      
<table border="1" width="100%">
  <tr>
          <td width="11%" height="13" valign="middle" align="center"><font face="Arial" size="2" color="#800000"><b><a href="Offers.jsp">Offers</a></b></font></td>
          <td width="20%" height="13" valign="middle" align="center"><font face="Arial" size="2" color="#800000"><b><a HREF="http://localhost:8000/music/shopping_cart.jsp">Shopping Cart</a></b></font></td>
          <td width="16%" height="13" valign="middle" align="center"><font face="Arial" size="2" color="#800000"><b><a HREF="http://localhost:8000/music/wishlist_page.jsp">Wishlist</a></b></font></td>
          <td width="8%" height="13" valign="middle" align="center"><font face="Arial" size="2" color="#800000"><b><a HREF="http://localhost:8000/music/feedback_page.jsp">Feedback</a></b></font></td>
          <td width="13%" height="13" valign="middle" align="center"><font face="Arial" size="2" color="#800000"><b><a HREF="http://localhost:8000/music/user_buy_page.htm">Buy</b></font></a></b></font></td>
          <td width="9%" height="13" valign="middle" align="center"><font face="Arial" size="2" color="#800000"><b><a HREF="http://localhost:8000/music/logout_page.jsp">Logout</a></b></font></td>
  </tr>
</table>
<table border="1" width="100%">
  <tr>
    <td width="18%">

<p><font face="Arial" size="2" color="#800000"><b><a HREF="http://localhost:8000/music/user_home_page.jsp">Home</a></b></font></p>

<p><b><font face="Arial" size="2" color="#800000"><a HREF="http://localhost:8000/music/chart_toppers.jsp">Chart Toppers</a></font></b></p>
<p><b><font face="Arial" size="2" color="#800000"><a HREF="http://localhost:8000/SearchContext/SearchAlias">Search</a></font></b></p>
<p><b><font face="Arial" size="2" color="#800000"><a HREF="http://localhost:8000/music/vote_page.jsp">Vote</a></font></b></p>

<p><b><font face="Arial" size="2" color="#800000"><a HREF="http://localhost:8000/Register/RegisterPage.htm">New Releases</a></font></b>
<p><font face="Arial" size="2" color="#800000"><b><a HREF="http://localhost:8000/music/register_page1.htm">Register</a></b></font>
<p><font face="Arial" size="2" color="#800000"><b><a HREF="http://localhost:8000/music/help_page.htm">Help</a></b></font></p>
<p>&nbsp;</p>
    </td>
    <td width="82%" valign="top">

<p><font face="Arial" size="2" color="#800000">Dear <%=session.getAttribute("username")%>,</font></p>
<p><font face="Arial" size="2" color="#800000">Your shopping cart contains
following items:</font></p>
<table border="0" width="105%">
  
  <tr>
  
<%! Vector vector=new Vector(1,1);%>

<%@ page import="java.util.*" %>
	<%@ page import="java.sql.*" %>
	<%@ page import="java.text.*" %>
	<%@ page import="java.sql.Date" %>

	<%@ page language = "java" %> 

	<%

Vector shoppingVectors=(Vector)session.getAttribute("Shopping_List");
int ctr=shoppingVectors.capacity();

int i=0;
try{

	for(;i<ctr;i++)
	{
		String str=((String)shoppingVectors.elementAt(i));
		
	}	
}
catch(Exception e)
{
	System.out.println("Exception " + e + "occured.");
}		
	

try{
	Enumeration paramNames = request.getParameterNames();


Vector existingVector=(Vector)session.getAttribute("Shopping_List");


    while(paramNames.hasMoreElements()) 
	{
   		   String paramName = (String)paramNames.nextElement();
		String str=request.getParameter(paramName);
	
		existingVector.addElement((String)paramName);
		     
	}	


session.setAttribute("Shopping_List", existingVector);	

}



catch(Exception e)
{
	System.out.println("Exception" + e+"occured");
}	
	

	
	try{
	Vector itemsInVectors=(Vector)session.getAttribute("Shopping_List");
	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	Connection connect;

	connect=DriverManager.getConnection("jdbc:odbc:RegisterDataSource","wasiqr","bhalbabatu");
	
	Statement state;
	
	state = connect.createStatement();
	
	String strQuery1 = "select * from Item_Master";
	String str, title, itemrate;
	ResultSet result1 = state.executeQuery(strQuery1);
	ResultSet result2;
	String strQuery2;
	int ctr1=0;
	String desc=new String("");
	String itemcode;
	float rate=0;
	int ctr2=0;
	float total=0;
 	out.println("<tr>");
out.println("<td width=\"11%\"><font face=\"Arial\" size=\"2\" color=\"#800000\"><b>Select</b></font></td>");
    out.println("<td width=\"11%\"><font face=\"Arial\" size=\"2\" color=\"#800000\"><b>Item Code</b></font></td>");
    out.println("<td width=\"18%\"><font face=\"Arial\" size=\"2\" color=\"#800000\"><b>Item Description</b></font></td>");
    out.println("<td width=\"10%\"><font face=\"Arial\" size=\"2\" color=\"#800000\"><b>Price ($)</b></font></td>");
out.println("<td width=\"10%\"><font face=\"Arial\" size=\"2\" color=\"#800000\"><b>Quantity</b></font></td>");
    
  out.println("</tr>");
  
  	while(result1.next())				
	{	
		
		itemcode=result1.getString("Item_Code");
		
		itemcode=itemcode.trim();
		
		if(itemsInVectors.contains(((String)itemcode)))
		{
		title=result1.getString("Title");
		itemrate=result1.getString("Rate");
out.println("<tr>");%>
<td width="11%"><font face="Arial" size="2" color="#800000"><input type="checkbox" name="+<%=itemcode%>+" value="<%=itemcode%>"></font></td>


<%


    out.println("<td width=\"11%\"><font face=\"Arial\" size=\"2\" color=\"#800000\">"+itemcode+"</font></td>");
		
    out.println("<td width=\"18%\"><font face=\"Arial\" size=\"2\" color=\"#800000\">" +title+"</font></td>");

    out.println("<td width=\"5%\"><font face=\"Arial\" size=\"2\" color=\"#800000\">"+itemrate+"</font></td>");
%>

<td width="10%"><input type="text" size="5"></td>

<%
out.println("</tr>");
		}
		ctr2++;
	}
		
	}
	catch(Exception e){
		System.out.println("done exception" +e);
	}	
	

 %>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <input type="submit" value="Add to Wishlist" name="Submit">&nbsp;&nbsp;<input type="reset" value="Reset" name="Reset"></p>
      <p>&nbsp;</td>

  </tr>


</table>

<p>&nbsp; </p>

<p>&nbsp; </p>
 
</form>

</body>

</html>

⌨️ 快捷键说明

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