2
   

Why Wont this work.

 
 
NeoGuin
 
Reply Fri 20 Dec, 2002 11:58 am
I'm trying to teach myself JSP and create something for my portfolio.

I decided to set up a prototype for an "Alternative" on-line bookstore.

Here's the code for an "Item Page"
Code:
<%@page contentType="text/html"%>
<html>
<head>
<style>
<!--Style Sheet-->
</style>
<title>Islam A Short History</title>
</head>
<body>
<%-- <jsp:useBean id="beanInstanceName" scope="session" class="package.class" /> --%>
<%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>
<table width='640'>
<tr>
<td width='640' colspan='2'>
<h1 align='center'>The People's Bookstore</h1>
</td>
</tr>
<tr>
<td width='640' colspan='2'>
<h2 align='center'>Knowledge Is Power</h2>
</td>
</tr>
<tr>
<td width='100'>
<IMG src='./Images/Islam.gif' alt='Islam--A Short History'>
</td>
<td width='540'>
 
<!--May become a review or suggestion area-->
</td>
</tr>
<tr>
<td width='640' colspan='2'>
<form action='./processOrder_DEBUG.jsp' method='get'>
<input type='hidden' name='title' value='Islam--A Short History'>
<b>Islam--A Short History<br>
Karen Armstrong</b>
<br>
<b>Price:</b> <input type='text' name='price' maxlength='7' value="$19.95"
readonly>
<!--For the price, may need to do some funny programming here-->
<input type='hidden' name='cost' value='19.95'>
<br>

<b>Amount:</b>
<select name='quantity'>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3.'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
</select>
</td>
</tr>
<tr>
<td width='640' colspan='2'>
<input type='submit' name='purchase' value='Purchase'>
<input type='reset' value='Cancel'>
</td>
</tr>
</form>
<tr>
<td width='640' colspan='2'>
<center>
<a href='Index.Jsp'>[Back To Home]</a>
</center>
</td>
</tr>
<tr>
<td width='640' colspan='2'>
<%@ include file='Copyright.html' %>
</table>
</body>
</html>


And the code for the order processor
Code:
<%@page contentType="text/html" import="java.lang.Float" %>
<html>
<head><title>JSP Page</title></head>
<body>
<%-- <jsp:useBean id="beanInstanceName" scope="session" class="package.class" /> --%>
<%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>
<%-- Get the variables from the referer page --%>
<%
//Declare the varaibles to hold the values
//String[] title, price, quantity;

String[] title;
String[] price;
String[] quantity;
//String total;

//For processing the price, quantity and total
Float flPrice, flQuantity;

//Fill in the variables
title= request.getParameterValues("title");
price = request.getParameterValues("cost");
quantity = request.getParameterValues("quantity");

//Some code to figure out the bill
flPrice = new Float(price[0]);
flQuantity = new Float(quantity[0]);

float totalCost = (flPrice.floatValue() * flQuantity.floatValue());

%>

<h1>THANK YOU</h1>

Your order is:
<br>
<b>Title:</b> <% out.print(title[0]); %><br>
<b>Quantity:</b> <%out.print(quantity[0]); %><br>
<b>Total:</b> <% out.print(totalCost); %><br>
</body>
</html>


I'm running Forte for Java and using the Tomcat server that came with Forte.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 2 • Views: 2,253 • Replies: 3
No top replies

 
Craven de Kere
 
  1  
Reply Fri 20 Dec, 2002 12:01 pm
I don't have time to pore over code but for the next person who tries to answer this:

What isn't working? What did you expect the code to do that is not happening?

Any error messages?
0 Replies
 
NeoGuin
 
  1  
Reply Fri 20 Dec, 2002 01:32 pm
I knew I forgot something
It doesn't go from the Item Page to the processor page.
0 Replies
 
Craven de Kere
 
  1  
Reply Fri 20 Dec, 2002 02:08 pm
I'm not that good with JSP and would have to configure a server (I am not on my PC and I don't have the option to install a server here) to see why that isn't working. So I can't say why the values aren't being passed (is the processing page named correctly? Is the capital letter in the action field correct?).

Another thing is that A2K is admittedly weak in this topic (web development) so this might not get answered till I beef up this category with more developers.
0 Replies
 
 

Related Topics

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » Why Wont this work.
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/26/2024 at 05:08:30