Please I need help with this so bad. I have been struggling with it for 2weeks now.
on line 206, I what to create a link that will direct you to the detail of the chosen items, like in the screenshot
Yes, I know the rules. This is a home and the class is for graduate student and I am an undergraduate. the teacher doesn't render any help whatsoever. check the comment on her rating,the last comment is the class I am taking with her. http://209.85.165.104/search?q=cache...ient=firefox-a
anyone that feels like giving me a personal assistant can pm me.
Thanks in Advance - /*
-
* OrderPage.java
-
*
-
* Created on October 16, 2007, 12:31 PM
-
*/
-
-
package ITIS5166;
-
-
import java.io.*;
-
import javax.servlet.*;
-
import javax.servlet.http.*;
-
import java.util.*;
-
import java.text.*;
-
-
/** Shows all items currently in ShoppingCart. Clients
-
* have their own session that keeps track of which
-
* ShoppingCart is theirs. If this is their first visit
-
* to the order page, a new shopping cart is created.
-
* Usually, people come to this page by way of a page
-
* showing catalog entries, so this page adds an additional
-
* item to the shopping cart. But users can also
-
* bookmark this page, access it from their history list,
-
* or be sent back to it by clicking on the "Update Order"
-
* button after changing the number of items ordered.
-
* <P>
-
* Taken from Core Servlets and JavaServer Pages 2nd Edition
-
* from Prentice Hall and Sun Microsystems Press,
-
* http://www.coreservlets.com/.
-
* © 2003 Marty Hall; may be freely used or adapted.
-
*/
-
-
public class ShopCartServletHW3 extends HttpServlet {
-
public void doGet(HttpServletRequest request,
-
HttpServletResponse response)
-
throws ServletException, IOException {
-
HttpSession session = request.getSession();
-
ShopCartDataHW3 cart;
-
synchronized(session) {
-
cart = (ShopCartDataHW3)session.getAttribute("ShopCartDataHW3");
-
// New visitors get a fresh shopping cart.
-
// Previous visitors keep using their existing cart.
-
if (cart == null){
-
cart = new ShopCartDataHW3();
-
session.setAttribute("ShopCartDataHW3", cart);
-
}
-
String itemID = request.getParameter("itemID");
-
if (itemID != null) {
-
String numItemsString = request.getParameter("numItems");
-
if (numItemsString == null) {
-
cart.addItem(itemID);
-
} else {
-
// If request specified an ID and number, then
-
// customers came here via an "Update Order" button
-
// after changing the number of items in order.
-
// Note that specifying a number of 0 results
-
// in item being deleted from cart.
-
int numItems;
-
try {
-
numItems = Integer.parseInt(numItemsString);
-
} catch(NumberFormatException nfe) {
-
numItems = 1;
-
}
-
cart.setNumOrdered(itemID, numItems);
-
}
-
}
-
}
-
// Whether or not the customer changed the order, show
-
// order status.
-
String straddress=request.getParameter("address");
-
String strshippingtype=request.getParameter("shippingtype");
-
String strcardtype=request.getParameter("cardtype");
-
String strcardnum=request.getParameter("cardnum");
-
String strcardname=request.getParameter("personname");
-
-
response.setContentType("text/html");
-
PrintWriter out = response.getWriter();
-
String title = "Status of Your Order";
-
String docType =
-
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
-
"Transitional//EN\">\n";
-
out.println(docType +
-
"<HTML>\n" +
-
"<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +
-
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
-
"<H1 ALIGN=\"CENTER\">" + title + "</H1>");
-
synchronized(session) {
-
List itemsOrdered = cart.getItemsOrdered();
-
if (itemsOrdered.size() == 0) {
-
out.println("<H2><I>No items in your cart...</I></H2>");
-
out.println
-
("<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
-
"<TR BGCOLOR=\"#FFAD00\">\n" +
-
" <TH>Item ID<TH>Description\n" +
-
" <TH>Unit Cost<TH>Number<TH>Total Cost");
-
-
out.println
-
("<TR>\n" +
-
" <TR bgcolor=#339900>" +
-
" <TD height=30> Shipping Information </TD></TR>" +
-
" <TR><TD WIDTH=200>" +
-
" <textarea name=address cols=50 rows=4></textarea></form></td>" +
-
" <TD><P>"+"<LABEL>" +
-
" <input type=radio name=shippingtype value=UPS Grounds>" +
-
" UPS Ground </label><br>" +
-
" <label>" +
-
"<input type=radio name=shippingtype value=UPS 2nd Day Air>" +
-
"UPS 2nd Day Air </label><br>" +
-
"<label><input type=radio name=shipping values=FedEx Priority>" +
-
"FedEx Priority </label><br>" +
-
"<label><input type=radio name=shippingtype value=FedEx Ultra>" +
-
"FedEx Ultra</label></p></form></td></tr>" +
-
"<tr bgcolor=#339900>" +
-
"<td height=30>Credit Card Information</td></tr>" +
-
"<tr><td height=40>Card Type: </td>" +
-
"<td colspan=4>" +
-
"<select name=cardtype value=visa>" +
-
"<option selected value=visa>Visa</option>" +
-
"<option value=MasterCard>MasterCard</option>" +
-
"<option value=America Express>America Express</option>" +
-
"<select></form></td></tr>" +
-
"<td height=30>Card Number:</td>" +
-
"<td colspan=4><input type=text name=cardnum> </form></td></tr>" +
-
"</form></td></tr>" +
-
"<tr><t height=30>Cardholder Name:</td>" +
-
"<td colspan=4><input type=text name=personname></form></td></tr><br>");
-
}
-
-
else {
-
out.println ("<table border=1>" +
-
"<tr bgcolor=#339900>" +
-
"<th width=90>Item ID<th>Description" +
-
"<th>Unit Cost <th>Number<th>Total Cost");
-
ItemOrder order;
-
-
NumberFormat formatter =
-
NumberFormat.getCurrencyInstance();
-
// For each entry in shopping cart, make
-
// table row showing ID, description, per-item
-
// cost, number ordered, and total cost.
-
// Put number ordered in textfield that user
-
// can change, with "Update Order" button next
-
// to it, which resubmits to this same page
-
// but specifying a different number of items.
-
for(int i=0; i<itemsOrdered.size(); i++) {
-
order = (ItemOrder)itemsOrdered.get(i);
-
out.println
-
("<TR>\n" +
-
" <TD>" + order.getItemID() + "\n" +
-
" <TD>" + order.getShortDescription() + "\n" +
-
" <TD>" +
-
formatter.format(order.getUnitCost()) + "\n" +
-
" <TD>" +
-
"<FORM>\n" + // Submit to current URL
-
"<INPUT TYPE=\"HIDDEN\" NAME=\"itemID\"\n" +
-
" VALUE=\"" + order.getItemID() + "\">\n" +
-
"<INPUT TYPE=\"TEXT\" NAME=\"numItems\"\n" +
-
" SIZE=3 VALUE=\"" +
-
order.getNumItems() + "\">\n" +
-
"<SMALL>\n" +
-
"<INPUT TYPE=\"SUBMIT\"\n "+
-
" VALUE=\"Update Order\">\n" +
-
"</SMALL>\n" +
-
"</FORM>\n" +
-
" <TD>" +
-
formatter.format(order.getTotalCost()));
-
}
-
-
if ((straddress!=null)&&(strshippingtype!=null)
-
&&(strcardtype!=null)&&(strcardnum!=null)&&(strcardname!=null))
-
{
-
out.println("<form action=PurchConfServletHW3 methed=Get>");
-
}
-
else{
-
out.println("<form action=ShopCartServletHW3 method=Get>");
-
out.println("Please enter your Information");
-
}
-
out.println(
-
-
"</tr>"+
-
"<tr bgcolor=#339900><td height=30 colspan=5>" +
-
"Shipping Information</td></tr>" +
-
"<tr><td with=200><textarea name=address cols=50 rows=4></textarea></td>" +
-
"<td colspan=4><p>"+"<label><br />" +
-
"<input type=radio name=shippingtype value=UPS Ground>" +
-
"UPS Ground </label><br>" +
-
"<label><input type=raio name=shippingtype value=UPS 2nd Day Air>" +
-
"UPS 2nd Day Air </label>" +
-
"<label><input type=radio name=shippingtype value=FedEx Priority>" +
-
"FedEx Priority <label>" +
-
"<label><input type=radio name=shippingtype value=FedEx Ultra>" +
-
"FedEx Ultra </label></p></td></tr>" +
-
"<tr bgcolor=#339900><td height=30 colspan=5>" +
-
"Credit Card Information</td></tr>" +
-
"<tr><td height=30>Card Type:</td>" +
-
"<td colspan=4><select anme=cardtype value=visa>" +
-
"option selected value=Visa>Visa</option>" +
-
"option value=MasterCard>MasterCard</option>" +
-
"option value=America Express>America Express</option></select></td></tr>" +
-
"<tr><td height=30>Card Number:</td>" +
-
"<td colspan=4><input type=text name=cardnum></td></tr></td></tr>" +
-
"<tr><td height=30>Cardholder Name:</td>" +
-
"<td colspan=4><input type=text name=personname></td></tr>" +
-
"tr bgcolor=#339900><td height=30><input type=submit name=Sumbit4 value=Purchase></td></tr>" +
-
"</form>");
-
String checkoutURL =
-
response.encodeURL("../Checkout.html");
-
// "Proceed to Checkout" button below table
-
out.println
-
("</TABLE>\n" +
-
"<FORM ACTION=\"" + checkoutURL + "\">\n" +
-
"<BIG><CENTER>\n" +
-
"<INPUT TYPE=\"SUBMIT\"\n" +
-
" VALUE=\"Proceed to Checkout\">\n" +
-
"</CENTER></BIG></FORM>");
-
}
-
out.println("</BODY></HTML>");
-
}
-
}
-
-
}
-
3 1643 ak1dnar 1,584
Recognized Expert Top Contributor
wrap your item description values with a anchor tag and pass the relevant URL parameters with the links to product_details page. all it depends on the way you have created your pages. for a example let's assume that these are your link to products on the description column on your shopping cart;
<a href="product_d etails.jsp?item _id=1001">Item 1001 description</a>
<a href="product_d etails.jsp?item _id=1002">Item 1002 description</a>
Then from the product_details .jsp get the "item_id" display the records for the item.
JosAH 11,448
Recognized Expert MVP
I'll move your question over to the Java Forum section.
kind regards,
Jos
JosAH 11,448
Recognized Expert MVP
Why don't you use a simple JSP page for the actual html output? If you try to
output everything from your single Servlet it becomes an untangible mess as
you can see already.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: TheLetti |
last post by:
Hy!
I've just downloaded the latest Java 2 SDK (j2sdk1.4.2_01).
For my surprise in this version the servlet-classes are not integrated
(e.g. the class javax.servlet).
So I found all the servlet-classes I needed on the
java.sun.com-Homepage and downloaded the javax.servlet-Package.
(Maybe this file-description may help you understanding my problem:
|
by: alan |
last post by:
Dear all,
I have a servlet problem.
When I modified my java servlet program and then uploaded it to my web
hosting server, then I start my web browser(I.E) to see the result.
But it loaded the previous java servlet class program. After several
days, these new classes file can be refreshed on browser.
I want to know how I can make sure I always see the most update
|
by: Rose Girl |
last post by:
Hi
Need some help on javascript. I need to know how to call a servlet
from a javascript function.
web-inf (jboss) path for servlet is:
com.purpleace.ripple.admin.contacts.servlet.AdminReport
web xml <servet-mapping> is :
|
by: sang |
last post by:
Hi
I prepared a program for Email Integration. That is email send to others through servlet's. I gave the code but it has some error in my code. Please check the code and give the feedback.
The Servlet code:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class MailServlet extends HttpServlet {
|
by: elsheh |
last post by:
I am trying to develop JavaServlet application using Apache Tomcat server. My application consists of two servlets and Java class for pooling connection. I need to include all my servlets in the same package (let’s call it, proj). The task of the first servlet is to build up an Web HTML form for gathering data. The second servlet does validation and store entry data to Database.
The problem is:
At first call for first servlet the application...
| |
by: Sushmita |
last post by:
hi all,
I have wrriten code for a small web application.
From my JSP page i am not able to call the servlet.. its throwing an exception.
"javax.servlet.ServletException: Wrapper cannot find servlet class servlet.IssueTrackerControllerServlet or a class it depends on
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
...
|
by: dmstn |
last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in another screen. All of this has to be done with java servlets. I think there's something I don't see and it's wrong. My problem is that anything I enter in the search bar appears as a result in the results page, even if there's not such a name in...
|
by: shiyamala |
last post by:
Hi i am shiyam,
i am having some problem in java, i am basic java programmer.
i have to write one program is writing the data into textfile name "newfile.txt" from one servlet and read it from another servlet its work but i want to know hw to deploy the readed input from textfile is displayed in jsp through servlet2.
here is my code
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import...
|
by: krishna81m |
last post by:
Hello,
I am looking for a solution to update a .jsp page (kind of progress bar) which shows current progress in a huge simulation when users have to wait for longer periods and the way to do it was have the jsp page refresh often and the page data update by a bean containing the properties file details. The main servlet class continously running on the server regularly updates the properties file.
I am currently using a properties file,...
|
by: mjahabarsadiq |
last post by:
Hi
I have created a servlet that is to be started at the server startup. And I got it.
In that I have created a object of another class and set it as a session attribute.
What I am trying is to get the object in a jsp page.
Following are the codes.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |