This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes changing sql qery at run time on a jsp page using jstl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "changing sql qery at run time on a jsp page using jstl" Watch "changing sql qery at run time on a jsp page using jstl" New topic
Author

changing sql qery at run time on a jsp page using jstl

Temitope Adedeji
Greenhorn

Joined: Sep 08, 2006
Posts: 3
changing sql qery at run time on a jsp page using jstl.wot di i do set a test or something?
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
First the standard disclaimer
- SQL should not be in a JSP. Put the code in a bean somewhere

If you MUST put SQL on a JSP page, then at least you are using the JSTL.
It depends what you are changing about it.

The best way to make a query dynamic is to parameterize it.
ie select username, useremail from userTable where userid = ?
and then use the <sql:param> tag to specify a value for the id.

If you want to dynamically construct sql (tables, columns to select) you are much better off doing it in java code where you can test/develop it outside of the application server.

Hope this helps,
evnafets
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: changing sql qery at run time on a jsp page using jstl