g118481
asked on
JSP page won't accept a variable in the Order By statement.
I have the code below in my JSP page.
The problem I am running into, is that when I use a variable in the Order By statement for the query, it doesn't recognize it.
If I hard code the Order By, it works.
This first part of code is looking for the Order_by in the url, if not found it defaults.
The second part of code is my query.
Can anyone see what I am doing wrong?
I outputed the URL variable Order_by to the screen, and it gets passed OK.
If I need to include all my page code, then let me know.
<%
String ORDER_BY = request.getParameter("ORDE R_BY");
if( ORDER_BY == null ) ORDER_BY = "CURDATE DESC";
%>
java.sql.ResultSet columns = statement.executeQuery("SE LECT * FROM MYTABLE WHERE REQOPEN='OPEN' AND NODENAME='CST' order by '"+ORDER_BY+"'");
The problem I am running into, is that when I use a variable in the Order By statement for the query, it doesn't recognize it.
If I hard code the Order By, it works.
This first part of code is looking for the Order_by in the url, if not found it defaults.
The second part of code is my query.
Can anyone see what I am doing wrong?
I outputed the URL variable Order_by to the screen, and it gets passed OK.
If I need to include all my page code, then let me know.
<%
String ORDER_BY = request.getParameter("ORDE
if( ORDER_BY == null ) ORDER_BY = "CURDATE DESC";
%>
java.sql.ResultSet columns = statement.executeQuery("SE
ASKER
Your answer does not make sense to me.
Please clarify.
Cheers
Please clarify.
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
java.sql.ResultSet columns = statement.executeQuery("SE
that will work