Hello all, the following code for a
JSP page genereates an error which states that the class file for this JSP page has a 'catch wihtout try' a 'try without catch' and needs another '}'. The page basically gets some values sent by the previous page and then either adds these to a class and forwards to the summary page or skips straight to the checkout page.
I can't see what's wrong with the code so I don't know why I've got this error, can anyone help?
<%@page import="java.sql.*, java.util.*, catalogue.*"%>
<jsp:useBean class="catalogue.ShoppingCart" id="cart" scope="session"/>
<%
String submit = request.getParameter("submit");
String product = (String)request.getParameter("product");
String artist = (String)request.getParameter("artist");
float price = Float.parseFloat(request.getParameter("price"));
if(submit.equals("Add")) {
BasketItem cd = new BasketItem();
cd.setTitle(product);
cd.setArtist(artist);
cd.setPrice((float)price);
cd.setQuantity(1);
cart.addItem(cd);
%>
<jsp:forward page="ShoppingCartSummary.jsp"/>
<%
}
else if (submit.equals("Checkout")) {
%>
<jsp:forward page="Checkout.jsp"/>
}
%>
Thanks.