I created a website using jsp and servlet. I made a shopping cart and got the items to display. But how can i remove the items from the cart? Next to each item is a remove button. When that is pressed the item selected needs to be removed and cart needs to refresh.
I am adding my shopping cart in session like bellow in servlet
HttpSession session = request.getSession(); session.setMaxInactiveInterval(60*30); // 30 minutes if (session.getAttribute("cart") == null){ session.setAttribute("cart", new ShoppingCart()); } cart = session.getAttribute("cart");
I seems if more than one person accesses it from server, if they items in the shopping cart, all the product is added to a single session. I mean if i added 4 items first and other person adds 2 items, second person sees 6 products in his cart. Where am I going wrong?
I am making a shopping cart app in JSP and servlets to bring it all together. Finally.
I have a registration servlet (c1), a registration form jsp (c2), a login jsp (c3). c1 checks if a username is in the database or not.
If the username is not there, then register the user and send them to c3. I want c3 to display a "registration successful" message if a user has just registered successfully and is coming from c1. ELSE, take the user back to c2 with a message which tells them to choose a different username or password etc.
How do I implement the logic of showing a message depending on where a user is coming from ? The servlets and jsps are ready and I only need to add this logic for a custom message. Of course, I could make a JSP for Registration Successful and one for Registration Failure. But, that seems to be unnecessary.
I am working on a project. It is a shopping cart java program that should be setup with an array size of 5 and increased at increments of 3 if you go over 5 items. When I go over 5 items in increases however it changes the item names to null. See output below.
Here is the actual assignment:
In this exercise you will complete a class that implements a shopping cart as an array of items. The file Item.java contains the definition of a class named Item that models an item one would purchase. An item has a name, price, and quantity (the quantity purchased). The file ShoppingCart.java implements the shopping cart as an array of Item objects.
1.Complete the ShoppingCart class by doing the following:
a.Declare an instance variable cart to be an array of Items and instantiate cart in the constructor to be an array holding 5 Items. b.Fill in the code for the increaseSize method. Your code should be similar to that in the CDCollection class handout but instead of doubling the size just increase it by 3 elements. c.Fill in the code for the addToCart method. This method should add the item to the cart and update the totalPrice instance variable (note this variable takes into account the quantity). d. Add a getTotalPrice() method to return the totalPrice. e..Compile your class.
2.Write a program that simulates shopping. The program should have a loop that continues as long as the user wants to shop. Each time through the loop read in the name, price, and quantity of the item the user wants to add to the cart. After adding an item to the cart, the cart contents should be printed along with a subtotal. After the loop, print a "Please pay ..." message with the total price of the items in the cart. Compile and run this class.
OUTPUT
Enter the name of the item: Apples Enter the unit price: .5 Enter the quantity: 1
Shopping Cart
ItemUnit PriceQuantityTotal Apples$0.501$0.50 Total Price: $0.50 Continue shoppping (y/n)? y Enter the name of the item: Oranges Enter the unit price: .5 Enter the quantity: 1
I am developing shopping cart in which I am storing image in database and retrieving.
When I select any product category from menu. example, I selected Computer then all list of product related to computer will be return i.e productName, Price and image, By using JSON.
this is my json response and output in comment.
success : function(data) { if (data.length != 0) { var d = eval(data); $("#productList").html(""); for ( var key in d) {
[Code] ....
Alternatively I created custom tag to resolve this.Custom tag is working fine in jsp but in java script it saying error raised Unterminated custom tag. I think I used this custom tag in javascript but i am not sure about this error,
custom tag code for image : imgByte = product.getImage().getBytes(1, (int) product.getImage().length()); String encodeimage = new String(Base64.encodeBase64(imgByte)); out.println("<tr><td><img src="data:image/jpeg;base64," +encodeimage + ""/><tr> <td>");
MY Question 1 - How can I use Custom tag in javascript ? Or 2 - How can we extract image from json object, like I did in custom tag .
I am making a shopping cart web, but some problems I meet about how to calculate the total price
I use ajax in product list web and if I choose one product , it will send the Id that I read from MySql to servlet and use session to save it . and I click the button jump to the cart, the page cart.jsp will read information from session ,and find product information from mysql by id , now my question is where I calculate the total price, servlet or jsp?
I'm working on a consulting training project to create a eCommerce online shopping application. Nothing big, just something functional and simple. That's why I want to structure it with the easiest maintainability possible. I've already ironed out the the database entities and how they'll relate to one another and even managed to establish connection to the database from my java application class. NOW I need to configure a user session on the web.xml, from what I've learned so far in my consulting, I can easily use jsp and servlets to have httpsession objects receive and send the information needed to and from the database, but the question is, how many do I need for a client's session?
Would maintainability be easier if I divide each entity's class actions to different servlets(a customer servlet, order servlet, product servlet, etc...), or can a single servlet handle an entire session without any complication?
I'm currently trying to build a project for a mock checkout system. Basically it has to allow for users to browse through a list of items and add and remove products to the shopping cart as well as keep track of everything, dynamically updating the total price of the items in the checkout. In addition I also have to allow for the use of multiple checkouts. I have the main gui built but just trying to ascertain the best manner in which to build everything behind it.
My program is basically on mall management ,here have to give details to customer of mall on a screen so, they can easily get that particular shop exact location . Infact they can get offer details that is given by that shop . Customer can even get alternate options of shop for their demand for eg: if someone want sports wear then he/she may get many options of shop like PUMA,NIKE,REEBOK etc.
I want to display product details such as product image, name, price in a one cell of a table tag on jsp page. There should be multiple rows and 3 cells per row in the required output.i have written the following code:
This code displays all cells in only one row. I used colspan but its not working...I have attached the snapshot of above code output and required output
I don't really get the concept of how I "insert" an item into an array. I get a cannot find symbol error when I try to. I think its because I'm losing focus. What sort of code would "insert" an item into an array? I just want a goal of conceptually how I would do it.
Anyways, here are the instructions for the exercise:
Write a new class method, insert, for the Item class that takes three arguments - an Item[] array, an Item newItem, and an int k - and inserts newItem into array at index k, discarding the last item of the array (that is, the item originally at index array.length - 1).
Here is the uneditable code:
public class Item { private int myN; public Item( int n ) { myN = n; } public String toString()
[Code] ....
I get a cannot find symbol error, but I thought I was doing as I was supposed to. I thought you had to have an ArrayList to be able to insert or delete an item from an array. How can you take a primitive object, like an array, and insert something into it. My idea of it was a[i] would be replaced with a[i + 1]. I know I'm getting this concept wrong because that's what I tried to do.
I need to choose the value of a list item in jsp. There are many employees in various departments and i need to choose that employees in department wise.
Example. I have two list items in jsp
1. Select dept_no,dept_name from departments 2. SElect emp_name from employees, departments where emp_dept_no=curr_dept_no and curr_dept_no = dept_no
These two are the list items. When i choose the department from the first list item i need to display the employees in that particular department in the second list.
I'm trying to make a calendar that, when you click on the date, the result are stored in a map and visualized in a table that refers to a container.
I successfully created the map mechanism, but I have a problem on the list....
I add the rows in this way:
Object newItemId = container.addItem(); Item riga = container.getItem(newItemId); riga.getItemProperty("Timestamp").setValue(fara); riga.getItemProperty("Date").setValue(asa); . How can I delete a row in the list, when all I have in input is the "Timestamp" information, in a Long value?
Can a JCalendar be used as an item. I cannot find and appropriate combodatepicker or at least one that looks like a standard combobox. I cannot get an answer from google search all i can get is how to add normal items.
So I drew a menu in DrawingPanel extends JPanel, that gets user input of number of players...etc. I also have a boolean, when true, the board is drawn, but apparently, right when I run, the boolean is checked, returns false and so board isn't drawn at all. When the user finishes input, the boolean becomes true, but the board doesn't get drawn. So my question is, how do I draw something not immediately when the program is ran?
I was wanting to select an item in a comboBox and display it in a text field but all it's doing at the minute is retrieving the first item in the comboBox and placing that in the txt field
String value = (String) comboBoxEnv.getSelectedItem().toString(); if(comboBoxEnv.getSelectedItem()!= null){ txtTo.setText(value);
I have an array list in my GUI class of an aplication , the app reads in 3 fields from the user and saves these to an array list allowing the user to enter more fields to be added to the arraylist, when displaying back out to the user the same entry displays multiple times, for example if i entered , a,b,1 then c,d,2 and then e,f,3 into the app when i press my display button it would just throw back e,f,3 three times rater than the three different entries...
Constructor and instance variables
private String name; private String number; private int year; private int count; private ArrayList<StudentData> myList; private StudentData myData;