Greetings,
I'm slowly building up code to do the following:-
- Display TWO selection option boxes (cascading).
- If the FIRST selection option box changes then reload the jsp using onchange event (not changing the option box value on relaod i.e. not re-running the SQL query).
- ONLY on initial entry should the form FIRST selection option box should be populated using JDBC SQL.
- The SECOND selection option box can then be populated from the value of the FIRST selection option box.
- Then when the selection is made from the SECOND selection option box display the correspong record details
My code was attempting to check the value of the option box and if it was null i.e. the first time the user had entered the screen then populate the Option value ELSE just forward its current Value which could be picked up by the SECOND selection box.
However I dont know how to check the Option value as I get the following error message due to me reloading the jsp I cant use getparameter:-
Originally Posted by
An error occurred at line: 12 in the jsp file: /examples/wk465682UserMenu.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequestAn error occurred at line: 12 in the jsp file: /examples/wk465682UserMenu.jsp
Generated servlet error:
OptionCategoryValue cannot be resolved
<!-- the % tag below is what is called a scriptlet tag - allows java to be embedded in the jsp -->
<%@ page import="java.util.*" %>
<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<HTML>
<H1>FAQ</H1>
<% String OptionCategory = null;%>
<H3>Please choose a category</H3>
<FORM ACTION="wk465682UserMenu.jsp" METHOD="POST">
<SELECT NAME="category" onChange="location.href='wk465682UserMenu.jsp?option='+this. value;">
<%
Connection conn = null, conn1 = null, conn2 = null;
if (request.getparameter("OptionCategoryValue") == 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:/ProgramFiles/Apache Software Foundation/Tomcat 6.0/webapps/2008-sem2/wk465682/FAQ.mdb");
}
catch (Exception e2) {System.out.print(e2);}
}
if(conn1 == null) conn = conn2;
else conn = conn1;
PreparedStatement mystatement = conn.prepareStatement("SELECT category from category");
ResultSet result = mystatement.executeQuery();
while(result.next()) {
OptionCategoryValue=result.getString(1); %>
<OPTION VALUE=OptionCategoryValue><%out.println(OptionCategory);%></OPTION>
<%}
} %>
</SELECT>
</FORM>
</HTML>