Greetings,
After changing all my jsp code to use Prepared statements I have an error in the below code.
The error is as follows:-
It doesnt appear related at all, line position isnt anywhere near the Prepared statement but Ive been trhoguh the code plenty of times even printed it out and used a marker pen (everythign appears to end with ';' where needed and the { } are equally numbered)
Can anyone spot the mistake? Maybe its time to take a break ....
After changing all my jsp code to use Prepared statements I have an error in the below code.
The error is as follows:-
org.apache.jasp er.JasperExcept ion: Unable to compile class for JSP
An error occurred at line: 12 in the jsp file: /examples/wk465682UpdateF AQ.jsp
Generated servlet error:
Syntax error, insert ";" to complete LocalVariableDe clarationStatem ent
An error occurred at line: 12 in the jsp file: /examples/wk465682UpdateF AQ.jsp
Generated servlet error:
Syntax error, insert ";" to complete LocalVariableDe clarationStatem ent
Can anyone spot the mistake? Maybe its time to take a break ....
Code:
<!-- the % tag below is what is called a scriptlet tag - allows java to be embedded in the jsp -->
<%@ page language="java" contentType="text/html" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<HTML>
<HEAD>
<TITLE>Update FAQ</TITLE>
<H3>UPDATE FAQ</H3>
<H4>Greetings, <%= session.getAttribute("theName") %></H4>
<BODY>
<%
Connection conn1 = null, conn2 = null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
conn1 = DriverManager.getConnection("jdbc:odbc:FAQ");
}
catch (Exception e1) {System.out.print(e1);}
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
conn2 = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver*.mdb)};DBQ=C:/Program // Files/Apache Software Foundation/Tomcat 6.0/webapps/2008-sem2/wk465682/FAQ.mdb");
}
catch (Exception e2) {System.out.print(e2);}
}
Connection conn;
if(conn1 == null) conn = conn2;
else conn = conn1;
String myquery = "SELECT category, question, answer, sequence from FAQ Where Id = ?" ;
PreparedStatement mystatement conn.prepareStatement(myquery);
mystatement.setInt(1,Integer.parseInt(request.getParameter("Id")));
ResultSet rs = mystatement.executeQuery();
if(rs.next()) {
String faqCategory=rs.getString(1);
String faqQuestion=rs.getString(2);
String faqAnswer=rs.getString(3);
Int faqSequence = rs.getInt(4);
%>
<FORM ACTION="wk465682updateFAQ2.jsp" METHOD="POST">
Category: <INPUT TYPE="text" NAME="faqCategory" READONLY="true" SIZE=55 VALUE="<%= faqCategory %>"><BR><BR>
Question<BR>
<TEXTAREA NAME="faqQuestion" COLS=100 ROWS=2> <%= faqQuestion %> </TEXTAREA><BR><BR>
Answer<BR>
<TEXTAREA NAME="faqAnswer" COLS=100 ROWS=4> <%= faqAnswer %> </TEXTAREA>
<INPUT TYPE="Int" VALUE="<%= faqSequence %>"><BR>
<INPUT TYPE="submit" VALUE=" Update ">
<INPUT TYPE="Reset" VALUE="Reset fields">
</FORM>
<%
}
%>
<form method="POST" action="wk465682AdminMenu.jsp" name="conform">
<table border="0" cellpadding="0" cellspacing="0" width="200" align="left">
<td width="50%" colspan="2" align="left">
<input type="submit" value="Return to Admin Menu" size="16">
</td>
</table>
</form>
</BODY>
</HTML>
Comment