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 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 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 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 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.
import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import javax.swing.ImageIcon; import javax.swing.JOptionPane; public class Main
[Code] ....
I cant custom my own icon. There is no error. But the image that I tried to show in the joptionpane is not showing. What should i do?
I am looking for a solution that will allow me to use a custom background image to replace the JFrame window. I am able to add a background Image, however I am not able to remove the "white" that is supposed to be transparent.
For example; if the image was shaped like a bird with transparent background (.PNG), I would like that to be put on the JFrame. Usually it will be a square with the image in the middle with white background, which I am unable to remove.
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'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 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
Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.
I stored an image into MySQL database using swings and hibernate but I am struggling to retrieve that image from MySQL database and display same image in the jTable cell and same as on jLabel whatever I retrieve from the database using swings and hibernate .
I'm trying to make a method that takes an image and turns it into a tile image. So if the original image looks like this:
[URL] ....
then the output image should look like this:
[URL] ....
Here's a method that's supposed to do that but for some reason the output image looks the same as the original:
public static int[][] tile(int[][] arr){ int[][] tile = new int[arr.length][arr[0].length]; for (int i = 0; i < arr.length; i++) { tile[i]=arr[i]; } return tile; }
I recently changed the method and the error message I'm getting is "bad operand types for binary operator '+'. Here's the method:
public static int[][] tile(int[][] arr){ int[][] tile = new int[arr.length][arr[0].length]; for (int i = 0; i < arr.length; i++) { for(int j=0; j<arr[i].length;j++){ tile[j]=(tile[j])+(arr[i]); } } return tile; }
I am working on a project that uses a custom tag in a JSP file. Here is the tag descriptor
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> <taglib> <tlibversion>1.0.0</tlibversion> <jspversion>1.1</jspversion>
[code]...
Everything seems working fine except that the custom tag handler does not get called at call. I set breakpoint and it never stops there. The JSP page is displayed fine, only not showing the custom tag content and there is no logged error/warning from the log. The tld is found fine. Like what classes called/validated the tag handler so I can logging those classes at DEBUG level to see what goes wrong.
I would like to create a custom tag which works similar to <c:forEach/> tag i.e
<c:forEach var = "movie" items = "${collection}> ${movie} </c:forEach>
I would want to create the similar behaviour(as above) in my own custom Tag.Morever I would like to use the doStartTag() and doEndTag() and doAfterBody() methods while creating custom Tag.