I have a jsp file were the db connection is created and queries can be executed.
I want to call these functions (of connecting to a database and executing query) from another jsp simply to add new record to a database and to stay on a same page.
I read here about an “import” tag but i don’t have any packages. Also i’m not allowed to use JSTL.
Little help?
Thanks for considering my question.
You can use
<%@include %>directive to statically include JSP fragments.Writing JSPs this way is however considered poor practice. Java code belongs in a Java class, not in a JSP file. You could for example use a preprocessing servlet class wherein you do the job in
doGet()method and have a reuseable DAO class wherein you hide all the JDBC boilerplate code away.