Above is my code :
con is an object of Connection
i keep getting null pointer exception when i try to use the returned connection inside JSP. well i pass con as an argument and call the method, the error appears in the method. But this works perfectly when running it as simple java.
java version 1.8
JDBC and JSP. i started jdbc just a month ago and jsp about 2 weeks ago.
And about this particular problem, i got the solution
seems i needed to add this little piece of code to the jsp and it worked
Thanks anyways. Hope to come back with lots of weird/ stupid questions.
Im learning on my own without any teachers so im sure that there'll be lots of it. thanks for Welcoming me :).
Bear Bibeault wrote:Is that not enough of a clue that you should/t be putting this in a JSP? Java code in a JSP is a huge no-no.
Leave the code in a Java class where it belongs.
And i still dont know how to write a scriptless JSP as of yet.
Ill learn it after i know how jsp actually works. for now im just mostly going about with what i know of java and what examples i see from the book and the internet
Bear Bibeault wrote:Not the best of ideas, in my opinion. Instilled bad habits are hard to break. I'd learn about JSTL and EL right away, and leave code techniques that have been obsolete for 14 years in the past.
I also recommend novices to JSP read:
The Secret Life of JSPs The Front Man
Thank you good sir. I will take your advice. I also believe in doing things the right way.
But doing things alone, its hard to find what that right way is.
Its always nice to know that people like you are there to guide people like us in the right path.
Hope you help me out more in the future too.