Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Apache Tomcat
|
Apache Tomcat General discussion of the Apache Tomcat servlet container. For discussions specific to the Professional Apache Tomcat book, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Apache Tomcat section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2008, 06:23 PM
Registered User
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nubileras Send a message via Yahoo to nubileras
Default Error Http 500 using jsp

Hi, I am new to using JSP and tomcat and I am trying to display images from my database but I keep getting this error.

An error occurred at line: 7 in the jsp file: /booksavers/categories.jsp
CatId cannot be resolved
4: <%
5: int CatID = Integer.parseInt(request.getParameter("CatID"));
6: PreparedStatement statement = con.prepareStatement("select * from Book where CatId = ?");
7: statement.setInt(1,CatId);
8: ResultSet resultSet = statement.executeQuery();
9: %>
10:


An error occurred at line: 18 in the jsp file: /booksavers/categories.jsp
CatId cannot be resolved
15: </head>
16:
17: <body>
18: <h1 align="center">Categories = <%= CatId %></h1>
19: <p>
20: <table align="center">
21: <tr>

I am not quite sure what is the problem here, the following below shows the code I have used.

<%@ include file ="connection.jsp" %>

<%
  int CatID = Integer.parseInt(request.getParameter("CatID"));
  PreparedStatement statement = con.prepareStatement("select * from Book where CatId = ?");
  statement.setInt(1,CatId);
  ResultSet resultSet = statement.executeQuery();
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Categories</title>
</head>

<body>
<h1 align="center">Categories = <%= CatId %></h1>

would someone please help me out with this.

Thanks

nubileras
 
Old July 27th, 2008, 11:35 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

The integer variable CatID is the problem. If you observe the following two lines taken from your code
int CatID = Integer.parseInt(request.getParameter("CatID"));
and
statement.setInt(1,CatId);

variable name is not the same. declaration uses 'CatID' and while using 'CatId'.
at line number two try using 'CatID'.


- Rakesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Http/1.1 500 Internal Server Error abinashpatra ASP.NET 1.0 and 1.1 Basics 17 May 10th, 2007 02:06 AM
asp error http 500 davidclangley ASP.NET 2.0 Basics 1 February 14th, 2007 06:18 AM
HTTP 500 - Internal server error helmsly BOOK: Beginning ASP 3.0 11 November 8th, 2006 03:15 AM
HTTP 500 error pjdas JSP Basics 0 November 21st, 2003 02:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.