Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers. I've gone ahead and added the code tags for you. See how much easier the code is to read?
Akash Thadani wrote:i am sorry did not know about that .. relatively new ot this but can you help me out with my problem here??
To be honest having scriptlets in your jsp page is a very bad practice. It's one of those things you shouldnever do. So you should seperate the business logic from the user interface. Use a Servlet to implement the business logic (connect to the database and insert the record) and use the jsp only to create the user interface (a form with a few buttons). So that would definitely be my first advice.
I did what you asked removed the scriplets out of my jsp and used java classes for my business logic but i am still not being able to connect to my database. I am using wamp server to use mysql ...is that okay??
i did not download mysql on my laptop. I can't seem to find the solution to my problem anywhere..
Another thing you should never do is include a JDBC driver (mysql.jar) INSIDE the WAR for your webapp.
Java is an expensive language to develop in, and therefore needs to justify itself. One of the ways it does that is that J2EE servers support Connection Pools which allow more efficient use of database resources. You should read up on how to use them.
For the record, a lot of us cringe when we read the words "i have created a dynamic web project". It's a giveaway that much of the serious thinking on your project was done by the IDE and not because you actually understood what you were doing.
An IDE is no substitute for an Intelligent Developer.
And if you still get the same ClassNotFoundException after refactoring your code, it's still the same issue and the MySQL JDBC driver seems to be not on your classpath. And if you don't have a driver, you won't be able to connect to your database.